I have a Stage Model, which belongs_to User Model. User Model has_many Stages.
When I try to create a New Stage, with an hidden_field containing the id of current_user ,
I have the following error :
ActiveRecord::AssociationTypeMismatch in StagesController#create
User(#63609336) expected, got String(#16545012)
Here’s the array :
{"utf8"=>"✓",
"authenticity_token"=>"YD3VVr9Hntg/LEGjFAzu2roR5NGe6FPclew+zJOvGpY=",
"stage"=>{"user"=>"8",
"intitule"=>"er",
"entreprise"=>"er",
"secteur"=>"er",
"mission"=>"er",
"duree"=>"erea",
"annee_debut"=>"az",
"annee_fin"=>"z",
"comment"=>"az",
"site_entreprise"=>"az"},
"commit"=>"Create Stage"}
user_id is an Integer field.
The view :
<%= f.hidden_field :user, :value => current_user.id %>
Where is the problem ? I can’t find any solution !
Thanks for your help.
replace with