ruby on rails - How to assign a variable the current output of a select tag -


i'm having trouble select tag.

i want assign value variable depending on name shown on select tag:

<%= select('product', 'name' , @products.map { |s| [s.name, s.id] }, {}, {:class => "form-control"}) %> 

the values display correctly, want assign selected value variable can used later on same page display content relevant details of selected product.

for example:

@product = currently_displayed_name 

is possible rails , how it? or might need use resource?

props comments, answer rails does not give way that. depending on need manipulate when user changes select value, might able find javascript library it.

otherwise, can load default variable on page, , handle rest onchange handler:

$('#product_name').change(function() {   // perform actions on page javascript }); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -