aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJosh Susser <josh@hasmanythrough.com>2011-11-27 14:12:46 -0800
committerJosh Susser <josh@hasmanythrough.com>2011-11-27 14:12:46 -0800
commit10834e975a54b63a07896cb8a6a16c336e20a792 (patch)
tree1c6011922f4745e85c69de565fe6cec7e8137f81 /activerecord/lib/active_record
parent61bcc318c865289d215e8e19618b9414bd07d1e8 (diff)
downloadrails-10834e975a54b63a07896cb8a6a16c336e20a792.tar.gz
rails-10834e975a54b63a07896cb8a6a16c336e20a792.tar.bz2
rails-10834e975a54b63a07896cb8a6a16c336e20a792.zip
changelog & docs for GeneratedFeatureMethods
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 34684ad2f5..60bbc325df 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -196,6 +196,26 @@ module ActiveRecord
# * <tt>Project#categories.empty?, Project#categories.size, Project#categories, Project#categories<<(category1),</tt>
# <tt>Project#categories.delete(category1)</tt>
#
+ # === Overriding generated methods
+ #
+ # Association methods are generated in a module that is included into the model class,
+ # which allows you to easily override with your own methods and call the original
+ # generated method with +super+. For example:
+ #
+ # class Car < ActiveRecord::Base
+ # belongs_to :owner
+ # belongs_to :old_owner
+ # def owner=(new_owner)
+ # self.old_owner = self.owner
+ # super
+ # end
+ # end
+ #
+ # If your model class is <tt>Project</tt>, the module is
+ # named <tt>Project::GeneratedFeatureMethods</tt>. The GeneratedFeatureMethods module is
+ # is included in the model class immediately after the (anonymous) generated attributes methods
+ # module, meaning an association will override the methods for an attribute with the same name.
+ #
# === A word of warning
#
# Don't create associations that have the same name as instance methods of