Home > Coding, GNU/Linux, Heroku, Rack, Rails > few tricks redirect domain with rails 2.1.0 on heroku

few tricks redirect domain with rails 2.1.0 on heroku


as i know, rails 2.1.0 has been depracted while using middleware option.

undefined method `middleware' for #<Rails

so, i can’t use it for the code on post previous.

but using this code will available to redirect main domain.

class ApplicationController                                              
  before_filter :ensure_domain                                            

  TheDomain = 'beta.deanet.web.id'

  def ensure_domain
    if request.env['HTTP_HOST'] != TheDomain
      redirect_to TheDomain
        end
   end
end

put on routes.rb .

real worlds: mainpagedeanet.heroku.com and beta.deanet.web.id

ref: docs.heroku.com/custom-domains

Advertisements
Categories: Coding, GNU/Linux, Heroku, Rack, Rails Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s