Browse files

Revert "Documents that ActiveRecord instances also support []/[]= met…

…hods for reading/writing attributes"

This reverts commit a49fe6e.

Reason: The existing doc about using self[:attribute] is clear enough.
  • Loading branch information...
1 parent 5916403 commit 83d4ce6a25efff9ae803a08a9895531aaecacd3c @vijaydev vijaydev committed Apr 7, 2012
Showing with 5 additions and 11 deletions.
  1. +5 −11 activerecord/lib/active_record/base.rb
View
16 activerecord/lib/active_record/base.rb
@@ -114,29 +114,23 @@ module ActiveRecord #:nodoc:
# Student.joins(:schools).where(:schools => { :category => 'public' })
# Student.joins(:schools).where('schools.category' => 'public' )
#
- # == Dynamic assignment
- #
- # Sometimes it can be useful to assign some attributes dynamically. You can use
- # <tt>read_attribute(attr_name, value)</tt>/<tt>write_attribute(attr_name)</tt>
- # or through model[attr_name]/model[attr_name]=:
- #
- # [:deleted, :disabled].each{|p| model[p] = params[p] == 'true' }
- #
# == Overwriting default accessors
#
# All column values are automatically available through basic accessors on the Active Record
# object, but sometimes you want to specialize this behavior. This can be done by overwriting
- # the default accessors (using the same name as the attribute):
+ # the default accessors (using the same name as the attribute) and calling
+ # <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually
+ # change things.
#
# class Song < ActiveRecord::Base
# # Uses an integer of seconds to hold the length of the song
#
# def length=(minutes)
- # write_attribute(:length, minutes.to_i * 60) # or: self[:length] = minutes.to_i * 60
+ # write_attribute(:length, minutes.to_i * 60)
# end
#
# def length
- # read_attribute(:length) / 60 # or: self[:length] / 60
+ # read_attribute(:length) / 60
# end
# end
#

0 comments on commit 83d4ce6

Please sign in to comment.