2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-01-31 20:44:30 -05:00
|
|
|
class Bird < ActiveRecord::Base
|
2011-12-14 21:13:03 -05:00
|
|
|
belongs_to :pirate
|
2009-01-31 20:44:30 -05:00
|
|
|
validates_presence_of :name
|
2010-01-08 14:47:49 -05:00
|
|
|
|
2011-12-14 21:13:03 -05:00
|
|
|
accepts_nested_attributes_for :pirate
|
|
|
|
|
2018-12-10 16:40:38 -05:00
|
|
|
before_save do
|
|
|
|
# force materialize_transactions
|
|
|
|
self.class.connection.materialize_transactions
|
|
|
|
end
|
|
|
|
|
2010-01-08 14:47:49 -05:00
|
|
|
attr_accessor :cancel_save_from_callback
|
2016-08-06 13:37:57 -04:00
|
|
|
before_save :cancel_save_callback_method, if: :cancel_save_from_callback
|
2010-01-08 14:47:49 -05:00
|
|
|
def cancel_save_callback_method
|
2014-12-15 01:10:15 -05:00
|
|
|
throw(:abort)
|
2010-01-08 14:47:49 -05:00
|
|
|
end
|
2011-12-14 21:13:03 -05:00
|
|
|
end
|