开发者

Rails 3: subdomain routes

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'
开发者_StackOverflow

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')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜