Ruby On Rails Paths
I am having trouble with paths in ruby on rails
My Routes:
map.resource开发者_如何转开发s :companies do |company|
company.resources :customers do |customer|
customer.resources :jobs
end
end
Currently I am creating the paths by hand:
<td><%= link_to 'Show', "/companies/#{params[:company_id]}/users/#{user.id}" %></td>
<td><%= link_to 'Edit', "/companies/#{params[:company_id]}/users/#{user.id}/edit" %></td>
For some reason I cant figure out how to get new_company_user to work I keep getting errors.
The routes are all there I just need help with dynamically creating them by using the API
If you'd like to use new_company_user
then you'd want something like this:
map.resources :companies do |company|
company.resources :users do |user|
user.resources :jobs
end
end
You can run rake routes
from the command line and it will print a list of all routes generated from routes.rb
, including named routes, the URL and HTTP request type that trigger them, and which controller action they run.
精彩评论