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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to