diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-01 17:54:45 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-01 17:54:45 +0000 |
commit | a390b2629a7de7cb8a8a5370aa493283c4a3f066 (patch) | |
tree | 95450d80d313e13c6a235c722761ea70aca54555 /activerecord/test/models | |
parent | a4ff4fd2c38175b38af928da2b5cae2b6bb19da7 (diff) | |
parent | 3be0ad60e4fcdafd4817508a21340dbf1bda6cb4 (diff) | |
download | rails-a390b2629a7de7cb8a8a5370aa493283c4a3f066.tar.gz rails-a390b2629a7de7cb8a8a5370aa493283c4a3f066.tar.bz2 rails-a390b2629a7de7cb8a8a5370aa493283c4a3f066.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/bird.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/parrot.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/pirate.rb | 7 | ||||
-rw-r--r-- | activerecord/test/models/ship.rb | 7 | ||||
-rw-r--r-- | activerecord/test/models/ship_part.rb | 5 |
5 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/test/models/bird.rb b/activerecord/test/models/bird.rb new file mode 100644 index 0000000000..341d2eeffc --- /dev/null +++ b/activerecord/test/models/bird.rb @@ -0,0 +1,3 @@ +class Bird < ActiveRecord::Base + validates_presence_of :name +end
\ No newline at end of file diff --git a/activerecord/test/models/parrot.rb b/activerecord/test/models/parrot.rb index b9431fd1c0..4a7ed52636 100644 --- a/activerecord/test/models/parrot.rb +++ b/activerecord/test/models/parrot.rb @@ -4,6 +4,8 @@ class Parrot < ActiveRecord::Base has_and_belongs_to_many :treasures has_many :loots, :as => :looter alias_attribute :title, :name + + validates_presence_of :name end class LiveParrot < Parrot diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb index 51c8183dee..6a2416a05c 100644 --- a/activerecord/test/models/pirate.rb +++ b/activerecord/test/models/pirate.rb @@ -5,5 +5,12 @@ class Pirate < ActiveRecord::Base has_many :treasure_estimates, :through => :treasures, :source => :price_estimates + # These both have :autosave enabled because accepts_nested_attributes_for is used on them. + has_one :ship + has_many :birds + + accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } + accepts_nested_attributes_for :ship, :allow_destroy => true + validates_presence_of :catchphrase end diff --git a/activerecord/test/models/ship.rb b/activerecord/test/models/ship.rb index 05b09fc1b9..c46e27f3ae 100644 --- a/activerecord/test/models/ship.rb +++ b/activerecord/test/models/ship.rb @@ -1,3 +1,10 @@ class Ship < ActiveRecord::Base self.record_timestamps = false + + belongs_to :pirate + has_many :parts, :class_name => 'ShipPart', :autosave => true + + accepts_nested_attributes_for :pirate, :allow_destroy => true + + validates_presence_of :name end
\ No newline at end of file diff --git a/activerecord/test/models/ship_part.rb b/activerecord/test/models/ship_part.rb new file mode 100644 index 0000000000..0a606db239 --- /dev/null +++ b/activerecord/test/models/ship_part.rb @@ -0,0 +1,5 @@ +class ShipPart < ActiveRecord::Base + belongs_to :ship + + validates_presence_of :name +end
\ No newline at end of file |