aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/pirate.rb
diff options
context:
space:
mode:
authorAlexey Kovyrin <alexey@kovyrin.net>2009-09-12 14:55:34 +0200
committerEloy Duran <eloy.de.enige@gmail.com>2009-09-12 16:04:36 +0200
commit938c0ee0455b8e784a771ce31631d9ec376ee6ab (patch)
tree22141b1db8c00aac3455f2ec5adbe6fa5227eacd /activerecord/test/models/pirate.rb
parent580ec0dccde075330abe68eb13badb03b225f9b4 (diff)
downloadrails-938c0ee0455b8e784a771ce31631d9ec376ee6ab.tar.gz
rails-938c0ee0455b8e784a771ce31631d9ec376ee6ab.tar.bz2
rails-938c0ee0455b8e784a771ce31631d9ec376ee6ab.zip
Define autosave association validation methods only when needed. [#3161 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Diffstat (limited to 'activerecord/test/models/pirate.rb')
-rw-r--r--activerecord/test/models/pirate.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb
index acf53fce8b..3d7c4bc48a 100644
--- a/activerecord/test/models/pirate.rb
+++ b/activerecord/test/models/pirate.rb
@@ -1,6 +1,8 @@
class Pirate < ActiveRecord::Base
- belongs_to :parrot
- has_and_belongs_to_many :parrots
+ belongs_to :parrot, :validate => true
+ belongs_to :non_validated_parrot, :class_name => 'Parrot'
+ has_and_belongs_to_many :parrots, :validate => true
+ has_and_belongs_to_many :non_validated_parrots, :class_name => 'Parrot'
has_and_belongs_to_many :parrots_with_method_callbacks, :class_name => "Parrot",
:before_add => :log_before_add,
:after_add => :log_after_add,
@@ -16,7 +18,8 @@ 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_one :ship, :validate => true
+ has_one :non_validated_ship, :class_name => 'Ship'
has_many :birds
has_many :birds_with_method_callbacks, :class_name => "Bird",
:before_add => :log_before_add,