Module: RedactorRails::Orm::ActiveRecord::AssetBase::ClassMethods

Defined in:
lib/redactor-rails/orm/active_record.rb

Class Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/redactor-rails/orm/active_record.rb', line 13

def self.extended(base)
  base.class_eval do
    self.table_name = "redactor_assets"

    belongs_to :assetable, :polymorphic => true
    belongs_to RedactorRails.devise_user, :foreign_key => RedactorRails.devise_user_key

    if defined?(ActiveModel::ForbiddenAttributesProtection) && base.ancestors.include?(ActiveModel::ForbiddenAttributesProtection)
      # Ok
    elsif defined?(ActiveModel::MassAssignmentSecurity) && base.ancestors.include?(ActiveModel::MassAssignmentSecurity)
      attr_accessible :data, :assetable_type, :assetable_id, :assetable
    end
  end
end