Archive

Posts Tagged ‘rack’

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

redirect domain using rack on rails on heroku

April 17, 2011 2 comments

Sudah satu minggu, kita ngoding ruby ngoprek lagi 😀 . masi dengan ruby.

kemarin sempet ngoprek RoR atau ruby on rails, ya iseng2 disaat sengggang kalo pas bosen ngadmin :D. ketemu masalah gimana cara bikin domain yang ada di heroku dengan aplikasi RoR hanya 1atau 2 lebih domain yg menghandle nya.

berikut contohnya:

Multiple domain list:
1. devel.heroku.com
2. coderiver.alinux.web.id

add on your environment.rb :
Read more…