2007-11-26 22:45:43 +00:00
|
|
|
class Ship < ActiveRecord::Base
|
|
|
|
self.record_timestamps = false
|
2009-02-01 01:44:30 +00:00
|
|
|
|
2009-11-06 22:53:33 +00:00
|
|
|
belongs_to :pirate
|
2009-12-28 20:08:20 +00:00
|
|
|
belongs_to :update_only_pirate, :class_name => 'Pirate'
|
2010-05-18 09:28:26 +00:00
|
|
|
has_many :parts, :class_name => 'ShipPart'
|
2009-02-01 01:44:30 +00:00
|
|
|
|
2010-05-18 09:28:26 +00:00
|
|
|
accepts_nested_attributes_for :parts, :allow_destroy => true
|
2009-02-08 13:23:35 +00:00
|
|
|
accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
|
2009-12-28 20:08:20 +00:00
|
|
|
accepts_nested_attributes_for :update_only_pirate, :update_only => true
|
2009-02-01 01:44:30 +00:00
|
|
|
|
|
|
|
validates_presence_of :name
|
2010-01-08 19:47:49 +00: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
|
2009-02-08 13:23:35 +00:00
|
|
|
end
|