Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 7805f0e0981afd70217ea4a30ea424c16fbd95c8 1 parent 4190966
Lennart Melzer authored grempe committed
View
4 generators/role_model/templates/migration.rb
@@ -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
View
4 generators/role_model/templates/role_model.rb
@@ -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
View
2  generators/role_model/templates/role_user_model.rb
@@ -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
View
4 lib/publishare/object_roles_table.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.