luissimo luissimo - 1 month ago 4
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?


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: