Sha256: f146b371b53023c86bdc8d1bcbaad1abbd6d79b2c2f471a360845ace2879c1dc
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module ActiveAdmin class Comment < ActiveRecord::Base self.table_name = 'active_admin_comments' belongs_to :resource, polymorphic: true belongs_to :author, polymorphic: true if defined? ProtectedAttributes attr_accessible :resource, :resource_id, :resource_type, :body, :namespace end validates_presence_of :body, :namespace, :resource before_create :set_resource_type # @return [String] The name of the record to use for the polymorphic relationship def self.resource_type(resource) ResourceController::Decorators.undecorate(resource).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, namespace: namespace.to_s ).order(ActiveAdmin.application.namespaces[namespace.to_sym].comments_order) end def set_resource_type self.resource_type = self.class.resource_type(resource) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-1.0.0 | lib/active_admin/orm/active_record/comments/comment.rb |