ruby on rails 4 - undefined method `model_name' for Module:Class -


i have form_for not meant initialize object, rather pass form data processing of web payment.

i advised form_for activemodelas means this.

it working fine while getting following error:

undefined method `model_name' module:class 

which being called on line:

  <%= form_for activemodel |f| %> 

in application/pay.html.erb file.

here full file:

<%= form_for activemodel |f| %>   <%= f.label :first_name %>   <%= f.text_field :first_name, params[:first_name] %><br />    <%= f.label :last_name %>:   <%= f.text_field :last_name, params[:last_name] %><br />     <%= f.label :card_number %>:   <%=f.text_field :card_number, params[:card_number] %><br />     <%= f.label :expiration_date %>:   <%= f.text_field :expiration_date, params[:expiration_date] %><br />     <%= f.label :cvv2_cvc2 %>:   <%= f.text_field :cvv2_cvc2, params[:cvv2_cvc2] %><br />    <%= f.submit %> <% end %> 

i think you've misunderstood.

activemodel module can include in model classes.

when calling form_for should reference instance of class includes activemodel, e.g.

form_for(@article) |f| 

model_name used rails determine name of model, submit button "update article" or "create article".


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -