This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Reverted last Actions to just alter the way

the default Join model is named.

It will now be named RolesUser to let Rails correctly
infer the table_name roles_users, which is hardcoded in
many places of the plugin.

Signed-off-by: Glenn Rempe <glenn@rempe.us>
  • Loading branch information...
1 parent 4190966 commit 7805f0e0981afd70217ea4a30ea424c16fbd95c8 Lennart Melzer committed with grempe Jan 10, 2009
@@ -1,7 +1,7 @@
class <%= migration_name %> < ActiveRecord::Migration
def self.up
- create_table :<%= (table_name < 'users') ? "#{singular_name}_users" : "user_#{table_name}" %>, :id => false, :force => true do |t|
+ create_table :<%= (table_name < 'users') ? "#{table_name}_users" : "users_#{table_name}" %>, :id => false, :force => true do |t|
t.integer :user_id, :<%= singular_name %>_id
t.timestamps
end
@@ -15,7 +15,7 @@ def self.up
def self.down
drop_table :<%= table_name %>
- drop_table :<%= (table_name < 'users') ? "#{singular_name}_users" : "user_#{table_name}" %>
+ drop_table :<%= (table_name < 'users') ? "#{table_name}_users" : "users_#{table_name}" %>
end
end
@@ -3,7 +3,7 @@
# "moderator" for an instance of a model (i.e., an object), a model class,
# or without any specification at all.
class <%= class_name %> < ActiveRecord::Base
- has_many :role_users, :dependent => :delete_all
- has_many :users, :through => :role_users
+ has_many :roles_users, :dependent => :delete_all
+ has_many :users, :through => :roles_users
belongs_to :authorizable, :polymorphic => true
end
@@ -1,5 +1,5 @@
# The table that links roles with users (generally named RoleUser.rb)
-class <%= (class_name < 'User') ? "#{class_name}User" : "User#{class_name}" %> < ActiveRecord::Base
+class <%= (class_name < 'User') ? "#{class_name.pluralize}User" : "Users#{class_name}" %> < ActiveRecord::Base
belongs_to :user
belongs_to :role
end
@@ -11,8 +11,8 @@ def self.included( recipient )
module ClassMethods
def acts_as_authorized_user(roles_relationship_opts = {})
- has_many :role_users, roles_relationship_opts.merge(:dependent => :delete_all)
- has_many :roles, :through => :role_users
+ has_many :roles_users, roles_relationship_opts.merge(:dependent => :delete_all)
+ has_many :roles, :through => :roles_users
include Authorization::ObjectRolesTable::UserExtensions::InstanceMethods
include Authorization::Identity::UserExtensions::InstanceMethods # Provides all kinds of dynamic sugar via method_missing
end

0 comments on commit 7805f0e

Please sign in to comment.