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.
collection_select_explain_3

11 Responses to “Rails collection_select helper”

  1. Chris says:

    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. admin says:

    Thansk Chris…glad if it did help someone to understand it better.

  3. Ben R says:

    You just saved my life. The ‘method” thing was killing me. Read this and it works.
    Thank you. Ben

  4. eeeeee says:

    you shrunk the image, now it’s unreadable unless you view it by URL: http://www.kahfei.com/wp-content/uploads/2009/06/collection_select_explain_3.png

  5. kahfei says:

    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.

  6. Alex says:

    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

  7. kahfei says:

    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.

  8. zora says:

    U just need to ‘Strg’ + ‘+’ to Zoom the pic ;-)

  9. eh says:

    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.

  10. kahfei says:

    eh, yes, definitely, am working on a new layout, ha, but the progress is really slow at the moment. ;-)

  11. [...] I have written about it, then I have a better understanding and longer memory. Like the collection_select method which I drawn a illustration and post about it sometimes ago, it stuck in my memory till [...]

Leave a Reply