Class: Para::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Para::ApplicationRecord
- Defined in:
- app/models/para/application_record.rb
Overview
Base class for all para-specific models.
Direct Known Subclasses
Cache::Item, Component::Base, ComponentResource, ComponentSection, Library::File, Page::Section, Page::SectionResource
Class Method Summary collapse
-
.with_belongs_to_optional_option_if_needed(&block) ⇒ Object
Adds the ‘optional: true` option to the belongs_to calls inside the provided block, but only for Rails 5.1+.
Class Method Details
.with_belongs_to_optional_option_if_needed(&block) ⇒ Object
Adds the ‘optional: true` option to the belongs_to calls inside the provided block, but only for Rails 5.1+
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/para/application_record.rb', line 10 def self.with_belongs_to_optional_option_if_needed(&block) belongs_to_accepts_optional = ActiveRecord::Associations::Builder::BelongsTo .send(:valid_options, {}) .include?(:optional) if belongs_to_accepts_optional (optional: true, &block) else block.call end end |