aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2011-06-13 13:02:51 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2011-06-13 13:02:51 +0100
commit5d655aabcb47a68e7ce1dfb60222e951a6d30169 (patch)
treed48691fbdf90430175a2132c18771be2644857bc /activerecord/test/models
parent987afa583e06a186a2c7235931dfd18d8d2d63a3 (diff)
downloadrails-5d655aabcb47a68e7ce1dfb60222e951a6d30169.tar.gz
rails-5d655aabcb47a68e7ce1dfb60222e951a6d30169.tar.bz2
rails-5d655aabcb47a68e7ce1dfb60222e951a6d30169.zip
Pass mass-assignment options to nested models - closes #1673.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/person.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
index a58c9bf572..967a3625aa 100644
--- a/activerecord/test/models/person.rb
+++ b/activerecord/test/models/person.rb
@@ -59,8 +59,9 @@ class LoosePerson < ActiveRecord::Base
has_one :best_friend, :class_name => 'LoosePerson', :foreign_key => :best_friend_id
belongs_to :best_friend_of, :class_name => 'LoosePerson', :foreign_key => :best_friend_of_id
-
has_many :best_friends, :class_name => 'LoosePerson', :foreign_key => :best_friend_id
+
+ accepts_nested_attributes_for :best_friend, :best_friend_of, :best_friends
end
class LooseDescendant < LoosePerson; end
@@ -70,11 +71,14 @@ class TightPerson < ActiveRecord::Base
attr_accessible :first_name, :gender
attr_accessible :first_name, :gender, :comments, :as => :admin
+ attr_accessible :best_friend_attributes, :best_friend_of_attributes, :best_friends_attributes
+ attr_accessible :best_friend_attributes, :best_friend_of_attributes, :best_friends_attributes, :as => :admin
has_one :best_friend, :class_name => 'TightPerson', :foreign_key => :best_friend_id
belongs_to :best_friend_of, :class_name => 'TightPerson', :foreign_key => :best_friend_of_id
-
has_many :best_friends, :class_name => 'TightPerson', :foreign_key => :best_friend_id
+
+ accepts_nested_attributes_for :best_friend, :best_friend_of, :best_friends
end
class TightDescendant < TightPerson; end \ No newline at end of file