Reputation: 10350
We define a hidden_field_tag in new.html.erb for invoice controller like this:
<%= hidden_field_tag :html_content_for_lease_record, '' %>
After assigning the new value to :html_content_for_lease_record
with javascript(we can see the new value in html source page for the hidden field), how can we retrieve the new value from invoice controller? We tried params[:html_content_for_lease_record]
and it returns nil. Thanks.
Upvotes: 0
Views: 618
Reputation: 12273
Here's how to do it with hidden_field
<--! note: TWO parameters below -->
<%= hidden_field :html_content_for, :lease_record %>
Assign a value via javascript and then to access it from your controller
params[:html_content_for][:lease_record]
By looking at the output from the terminal that's running your web server you should be able to see all the params being passed to your controller. Based on that you can easily find the param value you need to use.
Upvotes: 1