I am setting up a Rails site using map.resources
and map.resource
, and I am encountering a limitation (as far as I know at least).
Here is my current routing.
map.with_options :conditions => { :subdomain => true } do |sub|
sub.root :controller => 'company'
sub.resource :company do |company|
company.resources :clients, :path_prefix => nil, :name_prefix => nil, :collection => { :sort => :post } do |clients|
clients.resources :projects, :path_prefix => ":client/:project"
end
end
sub.resource :user, :collection => { :logout => :get }
end
In a general sense this is my wanted outcome:
/client-name/action
Calls the Clients controller, and passes the client-name as some sort of hash that is the same.
/client-name/project-name/action
Calls the Projects controller, but passes the client-name as a hash that stays the same. It wants to pass that as an id.
I am hoping to keep my URL structure very basic, so:
- client-name = yahoo
- project-name = login-page
/client-name/ - This should use the Clients.show
method.
/client-name/edit - This should use the Clients.edit
method.
/client-name/project-name - This should use the Projects.show
method.
/client-name/project-name/edit - This should use the Projects.edit
method.
Although with my current routing it is being interpreted as such:
/client-name/projects - This is using the Projects.index
method.
/clients/client-name - This is using the Clients.show
method.
I really appreciate any help that is given.