Cameron Bass Cameron Bass - 1 year ago 87
Ruby Question

Pass plan_id into params with submit button

I need to have two submit buttons in one form. The first one also needs to pass plan_id params with it. So basically I need this in my controller params

. Right now my submit button looks like this
<%= f.submit "Select", class: "button-big reverse-blue", name: "plan_id", value: "1" %>
This does not work, if I put a pry in the create action I have no params for plan id. My question is this, how can I pass the plan_id of 1 into the form submit button?


<%= f.submit "Select", class: "button-big reverse-blue", name: "plan_id", value: "1" %>

Answer Source

Why don't you use an hidden field in your form for that? Something like

<%= f.hidden_field :plan_id, value: plan_id %>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download