views:

25

answers:

1

Hi,

I am really confused with select boxes in ROR. How can I generate a working select box by using options_from_collection_for_select. This will only generate the option tags and not the select tag? Can anyone please provide me an example on how to use this.

I am having a hard time understanding select boxes, I don't know why...

Thanks

A: 
<% options = options_from_collection_for_select(@awesome_options, 'id', 'name') %>
<%= f.select :awesome_column, options %>

If you could give a little more insight into the error you are getting, we might be able to provide you with a better answer, but I believe the above is the basic gist of options_from_collection.

theIV
I don't get an error... I just couldn't figure it out the select box and how to use it. I see what you did and now it makes sense. @awesome_options, it should be an array, correct?
iHeartDucks
This did help me. Thanks. I have asked another question related to selecting an option in the select box. I am pasting the link here, hoping that you would want to take a look at ithttp://stackoverflow.com/questions/2196919/selecting-a-value-from-the-select-box-when-options-added-by-an-ajax-call
iHeartDucks