I have problem with rails routing.
Error is:
No route matches {:controller=>"orders", :action=>"sell_item"}
Route rule looks like:
match 'orders/sell/:id' => 'orders#sell_item', as: 'sell_item'
link generation in the view file:
<%= link_to 'sell', sell_item_url, id: line_item.id %>
function in the OrdersController
def sell_item(line_item_id)
line_item = LineItem.find(line_item_id)
line_item.status = 1
line_item.save
end
It still generates route if I remove ‘/:id’ from route and ‘,id: line_item.id’ from link_to.
Instead of
try
Rails should build the route for you based on the object.
See here:
http://guides.rubyonrails.org/routing.html#creating-paths-and-urls-from-objects