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

12 comments:

Roger Pack said...

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

Jim said...

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

Stephen said...

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

bparanj said...

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

Hasani Karunasekara said...
This comment has been removed by the author.
bhargavi said...

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

Pep said...

Thanks a lot.

Daniel said...

thanks seriously helped me out

mattc said...

Thanks for this, just what I was looking for.

Anonymous said...

Thanx man! Ver usefull!

mrberryman said...

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

Anonymous said...

Thank you!!