-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using namespaced classed does not work #75
Comments
I'm also using namespaces, and running into exactly the same problem. If I'm reading the code correctly, the issue lies in lib\rolify.rb, line 21:
I reckon I'm going to fork this and then pass the join table through as an option. Will send through pull request if I come right fixing the namespace support. |
Hi, are you using folder naming convention to split your user classes ? like |
Huh long time ago, yes I placed my files according to naming convention. Did you notice the slashes in sql-exception ? I continued using rolify without a namespace, but this is not my prefered 'workaround'. Would be nice, if this get's fixed. |
Hi guys, I've got a fork that is handing namespaces, I just need to get around to submitting a pull request. Not long hopefully :) |
I have run into this issue myself and have solved it by replacing the use of tabelize on the class name to calling table_name on the class itself. This will always return the correct table name. I have also updated this in the activerecord connector but have left the MongoDB connector as is as I do not use it and I have no means to test it. I will attach a pull request for this. |
namespaced models should be supported now. You can look in the specs to see how to use them. |
Hey thanks for doing this. But currently I discovered some problems to get this working in the right way: And first of all, the generators do not work, they still adding slashed instead of underscores to all relevant definitions. When i try to do some seeding, I'm getting this exception: SQLite3::SQLException: no such column: auth_users_auth_roles.user_id: SELECT 1 FROM "auth_roles" INNER JOIN "auth_users _auth_roles" ON "auth_roles"."id" = "auth_users_auth_roles"."role_id" WHERE "auth_users_auth_roles"."user_id" = 2 AND "auth_roles"."id" = 1 LIMIT 1 So I fixed manually the migration to and updated all index-defintions. Now I'm able to perform the seeding. But I'm aksing myself, if I could run into more problems, cause of this manually fix ?! Did I miss anything? Thanks in advance |
Right, the generator has not been modified as far as I remember. I will look into it to make them support namespaced models |
Hi, I started using rolify but I ran into several problems, if I want to use my User-Class which is namespaced via "Auth::User".
Running: rails generate rolify:role "Auth::Role" "Auth::User"
Causes: a nonworking migrationfile starting with:
class RolifyCreateAuth::Roles < ActiveRecord::Migration # look at the ::Roles
and each table got named with slashed like:
create_table(:auth/roles) do |t|
OK I changed the whole stuff such that is uses underscores instead of slashes and also updates the model-files such that:
class Auth::Role < ActiveRecord::Base
#OLD: has_and_belongs_to_many :auth/users, :join_table => :auth/users_auth/roles
has_and_belongs_to_many :auth_users, :join_table => :auth_users_roles
belongs_to :resource, :polymorphic => true
attr_accessible :name
end
AND
class Auth::User < ActiveRecord::Base
rolify:role_cname => 'Auth::Role'
has_and_belongs_to_many :auth_roles, :join_table => :auth_users_roles
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
end
But when I try to setup a seeds.rb like:
role1 = Auth::Role.create! :name => 'guest'
role2 = Auth::Role.create! :name => 'root'
user1 = Auth::User.create! :email => 'approot@test.de', :password => 'test', :password_confirmation => 'test'
user1.add_role :root
it causes an exception:
SQLite3::SQLException: no such table: auth/users_auth/roles: SELECT 1 FROM "auth_roles" INNER JOIN "auth/users_auth/rol
es" ON "auth_roles"."id" = "auth/users_auth/roles"."role_id" WHERE "auth/users_auth/roles"."user_id" = 1 AND "auth_roles
"."id" = 2 LIMIT 1
It seems that rolify has some hardcoded statements ?! Or what could be the problem ? Have I missed another option ?
Thanks in advance, Micha
The text was updated successfully, but these errors were encountered: