Rails collection_select helper

The explanation from api.rubyonrails.org is rather baffling for a newbie like me,

collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})

Still managed to get the dropdown menu working for my application after searching through the web. There are already quite a few useful resources available in the net for helper method collection_select.

But I seem to lost in the code again looking back at it after a while. And am too lazy to look through all the stuff again. So I try to make a diagram to put down what I already understand from those resources. Might not be the best or complete explanation, but just try to help myself to be able to view it and quickly get a grasp of it.

12 thoughts on “Rails collection_select helper

  1. Have to say this is not the most comprehensive collection_select post out there BUT it is straight to the point and illustrates the theory perfectly. Good job

  2. eeeeee, sorry for the problem, I am changing my blog layout, and seeing some images are exceeding the blog width, so I shrunk them. I will try to fix it over the weekend.

  3. Great post about collection_select. You just saved some hours of my life. Thanks a lot 🙂
    P.S. The image is little, though it’s readable enough

  4. Hi Alex,

    Glad that it is useful to you.
    I plan to redrawn the image so it is more visible, as soon as I find the time to do it.

  5. the image is fine, it just needs to be displayed normally. and not to complain, but hardset 400px content columns are user-hostile and lame.

  6. I am using the multi select, but i have a edit form and when i try get the values that were stored in the db it doesn’t render as selected, any advice?

Leave a Reply

Your email address will not be published. Required fields are marked *