i'm upgraded rails 3.2.13 , i'm migrating old app run in new environment (ruby1.9.3). app ran fine ruby192 , rails 3.0.0.
i receiving error when trying create new record (a firefighter)
wrong number of arguments (3 2)
and here code form
<%= form_for :fire_fighter, @fire_fighter, :url => { :action => "create" } |f| %>
based on reading other posts, recommend remove "fire_fighter" this
<%= form_for :@fire_fighter, :url => { :action => "create" } |f| %>
this did allow page render when tried enter fill in text fields , submit or create record in database error message built app says:
all of fields setup strings.
oh , had fields filled out before hit submit. i'm stuck.
any appreciated thanks.
although answer may change when post page source code , rest of form code, trying create symbol instance variable.
<%= form_for :@fire_fighter, :url => { :action => "create" } |f| %>
notice :@fire_fighter
. should @fire_fighter
. correct code should be
<%= form_for @fire_fighter, :url => { :action => "create" } |f| %>
the reason why use instance variable @fire_fighter
because in controller there should
def new @fire_fighter = firefighter.new end
that way, form directly grabbing instance variable controller onto form. symbols don't transverse controllers views, instance variables do, hence use of @fire_fighter
first argument in form_for
method.
Comments
Post a Comment