vendor/rails/activerecord/test/models/pirate.rb in radiant-0.8.2 vs vendor/rails/activerecord/test/models/pirate.rb in radiant-0.9.0.rc2

- old
+ new

@@ -1,8 +1,10 @@ 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, :before_remove => :log_before_remove, :after_remove => :log_after_remove @@ -15,10 +17,11 @@ has_many :treasures, :as => :looter 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 :non_validated_ship, :class_name => 'Ship' has_many :birds has_many :birds_with_method_callbacks, :class_name => "Bird", :before_add => :log_before_add, :after_add => :log_after_add, :before_remove => :log_before_remove, @@ -36,9 +39,13 @@ validates_presence_of :catchphrase def ship_log @ship_log ||= [] + end + + def reject_empty_ships_on_create(attributes) + attributes.delete('_reject_me_if_new').present? && new_record? end private def log_before_add(record) log(record, "before_adding_method")