To use an <input type=“hidden” /> tag, use the following syntax:
<% form_for(@post) do |f| %> <%= f.hidden_field :user_id, { :value => user.id } %> <% end %>