为此,我将嵌套在一个块内:
map.resources :customers do |customer|
customer.resource :quote do |quote|
quote.resources :first_resources
quote.resources :second_resources
end
end
替代语法:
map.resources :customers do |customer|
customer.resource :quote, :has_many => [:first_resources, :second_resources]
end
这会给你的网址
customers/:customer_id/quote/first_resources/:id
customers/:customer_id/quote
customers/:id
或者您提供的方式,我相信您需要映射复数引号,以便能够在您不想嵌套时获得特定的报价
map.resources :customers, :has_one => :quote
map.resources :quotes, :has_many => [:first_resources, :second_resources]
这会给你的网址
customers/:customer_id/quote
customers/:id
quotes/:quote_id/first_resources/:id
我认为第一个是你所追求的。希望这可以帮助。
资源: http ://api.rubyonrails.org/classes/ActionController/Resources.html