Sha256: 260d2eef16f205d13c4b7d264df5fea5c07ed7e20cd0e5740c159b7dfd049fbc
Contents?: true
Size: 672 Bytes
Versions: 12
Compression:
Stored size: 672 Bytes
Contents
module Para # Base class for all para-specific models. # class ApplicationRecord < ActiveRecord::Base self.abstract_class = true # Adds the `optional: true` option to the belongs_to calls inside the provided block, # but only for Rails 5.1+ # 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 with_options(optional: true, &block) else block.call end end end end
Version data entries
12 entries across 12 versions & 1 rubygems