Reputation: 1426
I have vendors/show view with button "Add new item" button. When i press "Add new item", it leads to items/new view with select which contain all Vendors.
I want to send vendor id value to items/new, that way it will be possible to show correct Vendor on my select.
How it can be done RIGHT?
Upvotes: 0
Views: 289
Reputation: 6225
Use nested resources:
map.resources :vendors do |vendor|
vendor.resources :items
end
Use new_vendor_item_path(vendor)
in vendors/show for "Add new item"
And in your item new
action:
@vendor = Vendor.find(params[:vendor_id])
Upvotes: 2