Friday, June 29, 2007

How to use hidden field in Rails

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

This passes a hidden variable user_id with the value of current_user.id

11 comments:

  1. or if you don't have f
    hidden_field_tag(:filter_only, :value => 1)

    ReplyDelete
  2. OP. thanks a lot for posting this i have been trying to do this for the past few hours...

    ReplyDelete
  3. Hey thanks for that! I wish the official documentation was this clear.

    ReplyDelete
  4. I committed this to docrails. So it should help out newbies in the future.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thanku So much... I was searching for this for hours....

    ReplyDelete
  7. thanks seriously helped me out

    ReplyDelete
  8. Thanks for this, just what I was looking for.

    ReplyDelete
  9. Anonymous7:09 PM

    Thanx man! Ver usefull!

    ReplyDelete
  10. You've saved my day! Or at least my hour.

    ReplyDelete
  11. Anonymous5:30 PM

    Thank you!!

    ReplyDelete