Sha256: 256b9433477729923eb5c39659fddb1c35070f2d73a6c6afc95b423d658c02a5
Contents?: true
Size: 1010 Bytes
Versions: 8
Compression:
Stored size: 1010 Bytes
Contents
class Ship < ActiveRecord::Base self.record_timestamps = false belongs_to :pirate belongs_to :update_only_pirate, :class_name => 'Pirate' has_many :parts, :class_name => 'ShipPart' has_many :treasures accepts_nested_attributes_for :parts, :allow_destroy => true accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } accepts_nested_attributes_for :update_only_pirate, :update_only => true validates_presence_of :name 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 class ShipWithoutNestedAttributes < ActiveRecord::Base self.table_name = "ships" has_many :parts, class_name: "ShipPart", foreign_key: :ship_id validates :name, presence: true end class FamousShip < ActiveRecord::Base self.table_name = 'ships' belongs_to :famous_pirate validates_presence_of :name, on: :conference end
Version data entries
8 entries across 8 versions & 1 rubygems