I have a Rails application that has a controller named domainthat has a nested controller named subdomainand stats. I defined them in routes.rb:
resources :domains do
resources :subdomains, :stats
end
I changed to_param of the domain and subdomain models to use the domain name, for example: the routing that I get http://site/domains/foo/subdomains/bar.
I would like to put it in order so that instead http://site/domains/foo/subdomains/barI can access it only with help http://site/foo/subdomains/bar. I tried the following in routes.rb:
match "/:id/" => "domains#show", :as => :domain
Which works great, but only gives me the opportunity to use the path http://site/foo, but for example http://site/foo/subdomains/barnot. I could create correspondence lines for each corresponding model and nested model, but it does nothing for other helpers except domain_url- that is, edit_domain_url points to /domains/foo/edit/instead /foo/edit.
Is there a way to change the routing so that it resourcesgenerates helpers pointing to the root URL without a part of the “domains”?
source
share