Archive

Archive for the ‘Rails’ Category

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: , ,