Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

f.hidden_field in rails 3.2

I am trying to insert a user id from devise into another table which collects contact details and company name and so on and i am using -

  <%= f.hidden_field :user_id, current_user.id %>

and all i seem to get back is an error on the page when i load it up -

undefined method `merge' for 1:Fixnum

Extracted source (around line #46):

am i missing something, do I have to put anything in the controller so i can access the current_user information?

Any help with this would be appreciated.

Robbie

like image 316
Robbie Done Avatar asked Apr 17 '12 12:04

Robbie Done


2 Answers

You can use it like

   <%= f.hidden_field :user_id, :value => current_user.id %>

or

   <%= hidden_field_tag "user_id",nil,:value => current_user.id %>

Try it..

like image 184
Kashiftufail Avatar answered Sep 30 '22 15:09

Kashiftufail


You can also do something like this.

<%= hidden_field_tag('some_object[user_id]', current_user.id)%>

like image 29
icantbecool Avatar answered Sep 30 '22 15:09

icantbecool