Reputation: 485
I want to pass a variable to a partial, then from the partial through a form to the controller, am I doing that correctly? The variable is called item_id.
<%= form_tag contribute_stripe_path, method: :post do %>
...
<%= hidden_field_tag item_id %>
...
@item_id = params[:item_id]
item = Count.find(@item_id)
...
item.update_attribute(:value, new_value)
post '/contribute', to: 'counts#stripe', as: 'contribute_stripe'
Upvotes: 0
Views: 30
Reputation: 3347
Posting the error usually helps.
What I see is the way you are defining the field is wrong.
<%= hidden_field_tag :item_id, item_id %>
The first param sets the field name, and the second one, its value (if the item_id
variable is defined... if not you will get an error)
Upvotes: 1