I''ve got a patch working for this and wanted to know the core-team''s opinion on this feature-add. I often find myself wanting to do finds with id''s and having the natural urge do to this. User[12] #=> User.find(12) Asking the User < ActiveRecord::Base object to give me an "index" on it... aka, the primary key... aka, the id. Any interest in this as a nice little shorthand? I''m asking here before making an actual-patch because I know that changes to ActiveRecord API are serious and I wanted to get opinions first. -hampton. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
In case you didn''t see it Jamis wrote about this a while back: http://weblog.jamisbuck.org/2007/4/4/activerecord-base-find-shortcut ::Jack Danger On 7/15/07, Hampton <hcatlin@gmail.com> wrote:> > > I''ve got a patch working for this and wanted to know the core-team''s > opinion on this feature-add. I often find myself wanting to do finds > with id''s and having the natural urge do to this. > > User[12] #=> User.find(12) > > Asking the User < ActiveRecord::Base object to give me an "index" on > it... aka, the primary key... aka, the id. > > Any interest in this as a nice little shorthand? I''m asking here > before making an actual-patch because I know that changes to > ActiveRecord API are serious and I wanted to get opinions first. > > -hampton. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 7/16/07, Hampton <hcatlin@gmail.com> wrote:> > > User[12] #=> User.find(12)I''ve sometimes been using it even before Jamis blogged about it and, naturally, I like it. http://weblog.jamisbuck.org/2007/4/4/activerecord-base-find-shortcut But would it cause confusion, chaos? Dunno. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
It''s a widely used technique already actually. Check http://weblog.jamisbuck.org/2007/4/4/activerecord-base-find-shortcut and comment section there to see why it''s not in core. Thanks, Pratik On 7/16/07, Hampton <hcatlin@gmail.com> wrote:> > I''ve got a patch working for this and wanted to know the core-team''s > opinion on this feature-add. I often find myself wanting to do finds > with id''s and having the natural urge do to this. > > User[12] #=> User.find(12) > > Asking the User < ActiveRecord::Base object to give me an "index" on > it... aka, the primary key... aka, the id. > > Any interest in this as a nice little shorthand? I''m asking here > before making an actual-patch because I know that changes to > ActiveRecord API are serious and I wanted to get opinions first. > > -hampton. > > > >-- http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 7/16/07, Pratik <pratiknaik@gmail.com> wrote:> > > Check http://weblog.jamisbuck.org/2007/4/4/activerecord-base-find-shortcut > and comment section there to see why it''s not in core.Hm, I''ve never really read the comments. There are some good arguments in there! I''m also in the "don''t add it" camp. It could really lead to confusion. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 15, 7:00 pm, "Mislav Marohnić" <mislav.maroh...@gmail.com> wrote:> I''m also in the "don''t add it" camp. It could really lead to confusion.Yeah, same here. But it makes a great plugin! ;) http://projects.wh.joshpeek.com/browser/plugins/find_shortcut --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
-1 Don''t add this to core, keep it as a plugin. For example, I use a plugin called "acts_as_lookup" in which you can do things like State["NY","California"] and State[5] where it will return the matching records. IMHO defining the [] method on AR objects should be done in plugins, or it should be gone all out with configurability options. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---