In Rails 2.3.8 if you put this in RAILS_ROOT/initializers/
# active_record_extensions.rb
module ActiveRecord
class Base
class << self
def [](index)
find(index)
end
end
end
end
Then you can access like an array:
User[17]
instead of the more verbose:
User.find(17)
Personally, I think it''s kinda nice.
David :)
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.