Quantcast
Channel: Define the default value of a drop down menu from a class variable - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by robe007 for Define the default value of a drop down menu from a...

According to the documentation about options_for_select, the second parameter is the selected value:options_for_select(container, selected = nil)So, the answer according to my question is:<%=...

View Article



Answer by Deem for Define the default value of a drop down menu from a class...

You can define the default value by using the :selected option:<%= s.select :category, :selected => params[:id] %>

View Article

Define the default value of a drop down menu from a class variable

I have a list of books categories on my db. I can get the value of them inside my controller like this:@categories = Book.uniq.pluck(:category) #programming, networking, infrastructureAnd then, I can...

View Article
Browsing all 3 articles
Browse latest View live


Latest Images