instiki/vendor/rails/activerecord/test/models/ship.rb

20 lines
654 B
Ruby
Raw Normal View History

class Ship < ActiveRecord::Base
self.record_timestamps = false
belongs_to :pirate
2010-05-25 19:45:45 +02:00
belongs_to :update_only_pirate, :class_name => 'Pirate'
has_many :parts, :class_name => 'ShipPart'
2010-05-25 19:45:45 +02:00
accepts_nested_attributes_for :parts, :allow_destroy => true
accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
2010-05-25 19:45:45 +02:00
accepts_nested_attributes_for :update_only_pirate, :update_only => true
validates_presence_of :name
2010-05-25 19:45:45 +02:00
attr_accessor :cancel_save_from_callback
before_save :cancel_save_callback_method, :if => :cancel_save_from_callback
def cancel_save_callback_method
false
end
end