Permalink
Browse files

Merge pull request #1641 from TaiGat/174-table-name-prefix

Overwrite self.table_name method in comment class.
  • Loading branch information...
2 parents 1b836ab + 9cc3449 commit 6148a3b47e8c339536d2e7a6bb4e800f426cddc0 @jpmckinney jpmckinney committed Sep 4, 2012
@@ -6,8 +6,6 @@ module ActiveAdmin
::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
@@ -41,6 +39,10 @@ def self.resource_id_type
columns.select { |i| i.name == "resource_id" }.first.type
end
+ def self.table_name
+ @table_name ||= ActiveRecord::Migrator.proper_table_name("active_admin_comments")
+ end
+
end
end
@@ -10,7 +10,8 @@ def self.up
# Update all the existing comments to the default namespace
say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
- execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
+ comments_table_name = ActiveRecord::Migrator.proper_table_name("active_admin_comments")
+ execute "UPDATE #{comments_table_name} SET namespace='#{ActiveAdmin.application.default_namespace}'"
end
def self.down

0 comments on commit 6148a3b

Please sign in to comment.