I'm trying to convert some subdomain routes from rails 2.3.x (with subdomain_routes plugin) like these:
map.subdomain :biz do |biz|
biz.resources :users
biz.resources :projects
biz.root :controller => 'home'
end
with those routes, i got urls like this:
http://biz.example.com/users # :controller => 'biz/users', :action => 'index', :subdomain => 'biz'
with rails3, there isn't subdomain_routes and I can't create the same kind of routes (even if I've read that is possible). Tried with this:
scope :module => :biz, :as => :biz do
constraints(:subdomain => 'biz') do
resources :users
resources :projects
root :to => 'Biz::HomeController#index'
end
end
but when trying on console, I don't get subdomain, so for: app.biz_users_url # http://www.example.com/users but not http://biz.example.com/users
I've also read/watched these resources, but there's no solution to my specific problem:
http://railscasts.com/episodes/221-subdomains-in-rails-3 http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up
any suggestions? thanks in advance ;)
A.
the above routes are correct, tha main problem was that they doesn't work with locahost. solved using http://lvh.me (a virtual domain that points to 127.0.0.1) as fake domain
You can get the URL with the subdomain making the following call app.biz_users_url(subdomain: 'biz')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With