Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] New Feature - grouped_collection_select

#1249

The disconnect between collection_select and option_groups_from_collection_for_select has been bugging me for some time, so I thought I'd quickly do something about it.

grouped_collection_select provides the same functionality as collection_select(object, method, collection), but uses the semantics and has the same output as option_groups_from_collection_for_select.

Example: grouped_collection_select(:destination, :country_id, @continents, :countries, :name, :id, :name)

It's not major, but I thought I'd quickly throw it in, hopefully someone finds it useful enough. Patch contains implementation, tests and doc, developed against Edge

Reported by Codeape · October 22nd, 2008 @ 02:38 PM

State: committed
Milestone: 2.3.4
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Amos King
    Amos King
    • Tag changed from feature, formoptionshelper to actionview, enhancement, formoptionshelper, patch

    I think the attempt to make the api consistent is great, and it sure is a lot less typing. You also documented and tested. You get my vote. +1

    December 16th, 2008 @ 02:39 PM

  2. Travis Briggs
    Travis Briggs

    I applied the patch, verified the functionality, and added a line to the doc showing the 'old' way of accomplishing the same thing.

    Everything looks good to me.

    March 10th, 2009 @ 04:23 AM

  3. Mike Breen
    Mike Breen
    • Assigned user set to Pratik
    • Tag changed from actionview, enhancement, formoptionshelper, patch to actionview, bugmash, enhancement, formoptionshelper, patch

    +1 for this change and I have verified that this patch applies cleanly to master.

    August 10th, 2009 @ 01:12 AM

  4. Mike Breen
    Mike Breen

    sorry, this does not apply cleanly to master:

    error: patch failed: actionpack/test/template/form_options_helper_test.rb:681
    error: actionpack/test/template/form_options_helper_test.rb: patch does not apply

    August 10th, 2009 @ 01:24 AM

  5. Erik Ostrom
    Erik Ostrom

    It didn't apply cleanly, only because some of the surrounding code had changed. I've attached a new patch, which is just Codeape's original patch semi-manually reapplied and rediffed. (The patch retains Codeape's authorship.)

    August 10th, 2009 @ 03:20 AM

  6. Rizwan Reza
    Rizwan Reza
    • Tag changed from actionview, bugmash, enhancement, formoptionshelper, patch to actionview, bugmash, enhancement, formoptionshelper, patch, verified
    • Title changed from New Feature - grouped_collection_select to [PATCH] New Feature - grouped_collection_select

    verified

    +1 This is a nice addition. The patch applies cleanly and all tests pass.

    August 10th, 2009 @ 03:25 AM

  7. Josh Nichols
    Josh Nichols
    • Tag changed from actionview, bugmash, enhancement, formoptionshelper, patch, verified to actionview, bugmash, enhancement, formoptionshelper, patch
    • Title changed from [PATCH] New Feature - grouped_collection_select to New Feature - grouped_collection_select

    Verified the updated patch applies to master.

    +1 on the functionality, but I'd like to see some example HTML output it produces.

    August 10th, 2009 @ 03:32 AM

  8. Erik Ostrom
    Erik Ostrom
    • Tag changed from actionview, bugmash, enhancement, formoptionshelper, patch to actionview, bugmash, enhancement, formoptionshelper, patch, verified
    • Title changed from New Feature - grouped_collection_select to [PATCH] New Feature - grouped_collection_select

    New patch. At Josh Nichols's suggestion, added sample output to the documentation, and used %Q{} to make the test a little more legible.

    August 10th, 2009 @ 04:10 AM

  9. Erik Ostrom
    Erik Ostrom

    New patch. At Josh Nichols's suggestion, added sample output to the documentation, and used %Q{} to make the test a little more legible.

    August 10th, 2009 @ 04:10 AM

  10. Ed Ruder
    Ed Ruder

    Verified.

    +1 this patch applies cleanly on 2-3-stable and all tests pass.

    August 10th, 2009 @ 06:06 AM

  11. Derander
    Derander

    +1 verified patch applies to master.

    This is a good idea, API consistency is A Good Thing™.

    August 10th, 2009 @ 07:07 AM

  12. Repository
  13. Repository
  14. Jeremy Kemper
    Jeremy Kemper
    • Tag changed from actionview, bugmash, enhancement, formoptionshelper, patch, verified to actionview, enhancement, formoptionshelper, patch, verified
    • Milestone changed from 2.x to 2.3.4

    August 10th, 2009 @ 08:02 AM