I try to create a partial with an update form for one of my models, but when I run the server and browse the page with the partial I get a strange exception:
NoMethodError in Simpadmin/transactions#index
Showing /home/ben/proj/Simplee/master/app/views/simpadmin/transactions/_transaction_actions.html.haml where line #17 raised:
undefined method `payments_transaction_path' for #<#<Class:0x00000007bf1768>:0x00000007bceb00>
Extracted source (around line #17):
14: %span.refund-success= flash[:refund_success]
15:
16: .refund-edit
17: = form_for transaction do |refund_form|
18: .refund-reason
19: = refund_form.label(:refund_reason, "Reason for refund:")
20: = select_tag(:refund_reason, options_for_select(possible_refund_emails), :class => 'refund-reason-select')
Trace of template inclusion: app/views/simpadmin/transactions/_
item.html.haml, app/views/simpadmin/transactions/index.html.haml
Maybe something is wrong with my routs (?)
Should I change something in the partial itself??
EDIT: The routes weren’t written by me. anyway, here is the transaction’s routes part:
resources :transactions, :only => [:index, :update, :show] do
155 collection do
156 get :export
157 post :edit_cashed_checks
158 put :update_cashed_checks
159 end
160 member do
161 match :update_payee, :via => [:post, :put]
162 match :add_comment, :via => :post
163 put :refund
164 end
165 end
As you are using the form_for and passing object of some model, in such cases rails implicitly assume the action to be invoked using the helper routine. Rails uses xyzs_path helper to find out the matching route, where Xyz is the model name whose object we are passing to form_for. It means there should be
or
matching named route
in your case, you need to define
or
named route