Is there a way to send an extra parameter through a form in rails 3?
For example:
<%= form_for @post do |f| %>
<%= f.hidden_field :extraparam, :value => "22" %>
<% end %>
but lets say :extraparam isn’t part of the post model..
I have an unknown attribute error in the create method of the controller when I try this, any ideas?
(I want to use the param value itself in the controller for some extra logic)
Call
hidden_field_tagdirectly. See: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-hidden_field_tagThese helpers exist for all the major form field types, and are handy when you need to go beyond your model’s methods.