I am using a hash constant in my ROR application. I want to show the names
from the hash constant to drop down.
helper.rb
PRODUCE_GROWING_METHODS = [
{id: 1, name: 'Conventional'},
{id: 2, name: 'Organic'},
]
def produce_growing_methods
PRODUCE_GROWING_METHODS
end
_produce.haml
= f.simple_fields_for :produce_details do |pd|
= pd.input :produce_growing_method, :collection => produce_growing_methods.collect { |x| [x[0], x[1]] }, :prompt => "Select Growing Method"
I tried as shown above in _produce.haml
but i am getting the empty drop down. Names
from the constant are not populated in drop down.
Can any one help me how to show the names
from the PRODUCE_GROWING_METHODS
hash constant to a drop down.
Thanks
Aucun commentaire:
Enregistrer un commentaire