Sha256: 4e71ddb96ca66a978c7b90162e0b96e633e70f7c04c360bcb8a7f1c27330175d
Contents?: true
Size: 869 Bytes
Versions: 7
Compression:
Stored size: 869 Bytes
Contents
require 'kaminari/models/active_record_extension' module ActiveAdmin # manually initialize kaminari for this model ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension class Comment < ActiveRecord::Base self.table_name = "active_admin_comments" belongs_to :resource, :polymorphic => true belongs_to :author, :polymorphic => true validates_presence_of :resource validates_presence_of :body validates_presence_of :namespace # @returns [String] The name of the record to use for the polymorphic relationship def self.resource_type(record) record.class.base_class.name.to_s end def self.find_for_resource_in_namespace(resource, namespace) where(:resource_type => resource_type(resource), :resource_id => resource.id, :namespace => namespace.to_s) end end end
Version data entries
7 entries across 7 versions & 2 rubygems