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.

Allow custom month ordering for select_month

#1574

Allow a custom month order to be specified for the select_month method. Useful when certain months should not be available for a particular scenario or a custom ordering is required.

Valid months for a school year for example could be Sept through June.

eg. :month_order => [2,3,4] only generates the select options for Feb, Mar, Apr in that order.

eg. :month_order => [11,12,1,2] only generates the select options for Nov, Dec, Jan, Feb in that order. - Useful for selecting months where a time period begins in one year and ends in another such as sport seasons, events and other schedules.

Reported by Andrew Kaspick · December 15th, 2008 @ 05:55 AM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Yaroslav Markin
    Yaroslav Markin

    I believe you should use a custom selector for that scenario, no? select_month part of datetime is already a bit too bloated.

    December 25th, 2008 @ 09:14 PM

  2. Andrew Kaspick
    Andrew Kaspick

    I've already had a need for this in 2 projects of mine, so I figure it may be useful for others and it's a pretty minor change. select_month doesn't seem overly bloated to me. (1..12) in the method is hard coded, so this just allows you to override that.

    December 28th, 2008 @ 07:20 AM

  3. Michael Koziarski
    Michael Koziarski
    • State changed from new to wontfix

    I agree with yaroslav here. There's already a tonne of options to those helpers, and we'll never be able to satisfy everyone.

    February 18th, 2009 @ 05:20 AM

  4. Andrew Kaspick
    Andrew Kaspick

    Fair enough, although...

    Less requests for custom options may occur if some of those month name related methods (the ones that give you "January","Jan",etc.) were more accessible for reuse, but right now they're all private and depend on the class var for the @options.

    I don't like copy and pasting rails methods that are more than a handful of lines long in order to customize them slightly as you then need to maintain them with each rails release. Using the existing select_month method gave me the month naming functionality "out of the box" which was a big benefit.

    On the path towards Rail 3, moving the month name methods to a more accessible spot for the "public" plugin/gem API may be something to consider.

    Thanks for reviewing anyway.

    February 18th, 2009 @ 05:51 AM