Permalink
Browse files

Missed some references to roles table.

To configure the table name:
    Sanction::Role.set_table_name "sanction_roles"
  • Loading branch information...
1 parent 1aab965 commit 81eaeccc72152355ffc0d23c0295c7c6f97b6e28 @crystalneth crystalneth committed Mar 4, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/sanction/permissionable/base.rb
@@ -4,7 +4,7 @@ module Base
def self.extended(base)
base.class_eval %q{
has_many :permissionable_roles, :as => :permissionable, :class_name => "Sanction::Role",
- :finder_sql => 'SELECT * FROM roles WHERE roles.permissionable_type = "#{self.class.name.to_s}" AND (roles.permissionable_id = "#{id}" OR roles.permissionable_id IS NULL)'
+ :finder_sql => 'SELECT * FROM #{Sanction::Role.table_name} WHERE #{Sanction::Role.table_name}.permissionable_type = "#{self.class.name.to_s}" AND (#{Sanction::Role.table_name}.permissionable_id = "#{id}" OR #{Sanction::Role.table_name}.permissionable_id IS NULL)'
has_many :specific_permissionable_roles, :as => :permissionable, :class_name => "Sanction::Role", :dependent => :destroy
}
@@ -14,7 +14,7 @@ def self.extended(base)
returned_scope = {:conditions => ["#{ROLE_ALIAS}.permissionable_type = ?", base.name.to_s], :select => "DISTINCT #{base.table_name}.*"}
unless already_joined
- returned_scope.merge({:joins => "INNER JOIN roles AS #{ROLE_ALIAS} ON #{ROLE_ALIAS}.permissionable_type = '#{base.name.to_s}' AND
+ returned_scope.merge({:joins => "INNER JOIN #{Sanction::Role.table_name} AS #{ROLE_ALIAS} ON #{ROLE_ALIAS}.permissionable_type = '#{base.name.to_s}' AND
(#{ROLE_ALIAS}.permissionable_id = #{base.table_name}.#{base.primary_key.to_s} OR #{ROLE_ALIAS}.permissionable_id IS NULL)"})
end
}
@@ -24,7 +24,7 @@ def self.extended(base)
returned_scope = {:conditions => ["#{klass_instance.class.table_name}.#{klass_instance.class.primary_key.to_s} = ?", klass_instance.id], :select => "DISTINCT #{klass_instance.class.table_name}.*"}
unless already_joined
- returned_scope.merge({:joins => "INNER JOIN roles AS #{ROLE_ALIAS} ON #{ROLE_ALIAS}.permissionable_type = '#{klass_instance.class.name.to_s}' AND
+ returned_scope.merge({:joins => "INNER JOIN #{Sanction::Role.table_name} AS #{ROLE_ALIAS} ON #{ROLE_ALIAS}.permissionable_type = '#{klass_instance.class.name.to_s}' AND
(#{ROLE_ALIAS}.permissionable_id = '#{klass_instance.id}' OR #{ROLE_ALIAS}.permissionable_id IS NULL)"})
end
}

0 comments on commit 81eaecc

Please sign in to comment.