Add find_last_by dynamic finder
Reported by miloops | August 5th, 2008 @ 02:55 PM | in 2.x
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.
Comments and changes to this ticket
-
-
-
Clemens Kofler August 8th, 2008 @ 03:36 PM
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.
-
miloops August 8th, 2008 @ 04:00 PM
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.
-
Clemens Kofler August 10th, 2008 @ 01:21 PM
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.
-
miloops September 1st, 2008 @ 05:37 PM
- no changes were found...
-
-
DHH September 10th, 2008 @ 05:46 AM
- → State changed from new to committed
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
The Git repository resides at http://github.com/rails
Check out the current development trunk (Edge Rails) with:
git clone git://github.com/rails/rails.git
Creating or reviewing a patch
See the contributor guide.
Creating a feature request
Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.
Creating a bug report
When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.
Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".
