luissimo luissimo - 1 year ago 78
HTML Question

How to pass a value to database without f.text_field Rails

Hi guys i have a value which i wan't to add to the database dynamically. The value is made with jQuery and it outputs to the

id 'invoice_total'
So based on the users input that value changes.
I want to save that value to the database while using something like
<p id="invoice_total"></p>
and not
<%= f.text_field :total, id: 'invoice_total' %>

How can i achieve this with RoR?

Answer Source

You can add a hidden field and when set the value to p set this input value:

<%= f.hidden_field :total, id: 'invoice_total_input' %>

and then you can do:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download