Permalink
Browse files

Merge pull request #1229 from fidel/attr_accessible

Fixed issue #1203
  • Loading branch information...
2 parents c183c89 + d40133d commit 753ff9022dfc15aad9479f99f6a1422d3158e537 @jancel jancel committed Apr 14, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/active_admin/comments/comment.rb
@@ -11,6 +11,8 @@ class Comment < ActiveRecord::Base
belongs_to :resource, :polymorphic => true
belongs_to :author, :polymorphic => true
+ attr_accessible :resource, :resource_id, :resource_type, :body, :namespace
+
validates_presence_of :resource
validates_presence_of :body
validates_presence_of :namespace
@@ -19,7 +21,7 @@ class Comment < ActiveRecord::Base
def self.resource_type(record)
record.class.base_class.name.to_s
end
-
+
def self.resource_id_cast(record)
# Postgres adapters won't compare strings to numbers (issue 34)
if resource_id_type == :string
@@ -31,11 +33,10 @@ def self.resource_id_cast(record)
def self.find_for_resource_in_namespace(resource, namespace)
where(:resource_type => resource_type(resource),
- :resource_id => resource_id_cast(resource),
+ :resource_id => resource_id_cast(resource),
:namespace => namespace.to_s)
end
-
def self.resource_id_type
columns.select { |i| i.name == "resource_id" }.first.type
end

0 comments on commit 753ff90

Please sign in to comment.