Hi there, I’m having a problem with the named url helpers the resource
mapper in routes.rb produces.
I have a model where a Vendor has_many Categories.
So I setup routing like so:
map.resources :vendors do |vendor|
vendor.resources :categories, :name_prefix => “vendor_”
end
This should provide me with…
vendor_category_path
vendor_edit_category_path
and vendor_new_category_path
But when I attempt to use those very helpers, I get this error:
ActionView::TemplateError (vendor_edit_category_url failed to generate
from
{:action=>“edit”, :controller=>“categories”, :vendor_id=>“1”}, expected:
{:action=>“edit”, :controller=>“categories”}, diff: {:vendor_id=>“1”})
on
line #12 of app/views/categories/index.rhtml:
9:
10:
%>
11:
12:
%>
13:
:confirm
=> ‘Are you sure?’, :method => :delete %>
14:
15: <% end %>
Am I misunderstanding something or is this bit of code still a work in
progress in Edge rails as far as nested resources are concerned? What
can I
do in the meantime to vendor_edit_category_url that it should be
expecting
a vendor_id in the mix?
Here’s a snippet of my view:
and in the view:
<% for category in @categories %>
Any help is much appreciated! Thanks.
D. Taylor S.
Reality Technician
“Look at my hair; like the design.” – David Byrne