Class: Glib::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Glib::ApplicationRecord
- Includes:
- EnumHumanization
- Defined in:
- app/models/glib/application_record.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from EnumHumanization
Class Method Details
.glib_has_one_attached(field_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/glib/application_record.rb', line 13 def self.glib_has_one_attached(field_name) has_one_attached field_name define_method("#{field_name}=") do |value| if value == '' send(field_name).detach else super(value) end end end |
Instance Method Details
#assert_core_columns_exist ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/models/glib/application_record.rb', line 25 def assert_core_columns_exist if Rails.env.development? || Rails.env.test? [:id, :created_at, :updated_at].each do |column_name| unless self.class.column_names.include?(column_name.to_s) raise ActiveRecord::ConfigurationError, "#{self.class.table_name}.#{column_name} should exist" end end end end |