Question

In my index.html.erb I have

<%= link_to 'Edit', edit_order_path(order) %>

Whenever I try to edit the order contents i got the following error:

NoMethodError in Order#index 
undefined method `edit_order_path' for #<ActionView::Base:0x13f4aeb>

How can I overcome it?

Was it helpful?

Solution

Add following line of code in your routes.rb resources :orders or add following line of code in routes.rb

match 'orders/:id/edit' => 'orders#edit', :as => :edit_order

I assume, your controller name as orders and action edit. use following code for form

<% form_for(@order, :url => {:action => :update}) do |f| %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top