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.

Add find_last_by dynamic finder

#762

In order to be consistent, an also helpful, dynamic finders should allow to find the last record with the same options as find_by and find_all_by are defined.

Following the principle of least surprise, "last" should adhere to all "first" semantics and conventions.

Reported by Emilio Tagua · August 5th, 2008 @ 11:02 PM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: Low

Activity

  1. Chris Lloyd
  2. Matt Darby
  3. Clemens Kofler
    Clemens Kofler

    Shouldn't findby be renamed to findfirst_by then? I don't know, perhaps it's just my general dislike of dynamic finders, but I'm kinda -1 on this. Sure, it doesn't do any damage but I don't think it adds real value either.

    August 8th, 2008 @ 03:36 PM

  4. Emilio Tagua
    Emilio Tagua

    Clemens,

    It's not about damage, it's about consistency.

    I don't think find_by should be renamed necessarily, i think that it is not bad at all to have a default, as find first is at the moment.

    There are 3 finders: first, all and last. And whether you use the 3 of them or not, or if you like using dynamic finders or not, the framework should treat equally and provide this shortcut for the 3 of them.

    August 8th, 2008 @ 04:00 PM

  5. Clemens Kofler
    Clemens Kofler

    I don't see the point in find(:last) either. After all, it doesn't make a difference if I say find(:first, :order => "something DESC") or find(:last, :order => "something ASC"). I think, just by itself, the naming of :first is the "weird" thing - it should rather be :single or :one.

    August 10th, 2008 @ 01:21 PM

  6. Emilio Tagua
  7. Emilio Tagua
    Emilio Tagua

    Patch rebased to master.

    September 1st, 2008 @ 05:54 PM

  8. DHH
    DHH
    • State changed from new to committed

    September 10th, 2008 @ 05:46 AM

  9. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:55 AM