I have dim_user
, dim_role
and role_user_map
tables. I am using rolify
gem for authorisation. I don't have role_id as primary key. In my case role_name is the primary key and my role_user_map table will have 2 columns (user_id, role_name) How to change default join_table name and other table names in rolify.rb
?

- 5,454
- 1
- 18
- 40

- 65
- 9
2 Answers
I'm not familiar with it but I did some reading on the Rolify github page The dim_role dim_user and role_user_map tables you had already before you installed the rolify gem? You're supposed to use the gem's generator to create the role model using the syntax rails g rolify You could pass in DimRole and DimUser as arguments instead of just Role and User but again, you're supposed to be letting the gem create the mapping table for you, not having already created it yourself

- 73
- 1
- 7
-
I already have a oracle database with these tables. In that case how to use it – Alia Tabassum Jan 07 '19 at 10:37
Look at /db/schema.rb and see the structure of the tables created by the gem then modify and or rename your existing tables to match what the gem expects their structure and names to be Seemingly if you have pre-existing map or "through" tables you're gonna have to fool the gem Create a temporary app and run the gems generator with the names of your pre-existing tables (i don't know if the gem runs migratoins, if not then you have to run rake db:migrate after) then examine the created tables in schema.rb Then go back to your development app and restructure the tables to match the tables in the temp app

- 73
- 1
- 7
-
1Are you writing essay? And why have you posted your so called answer in 2 different posts? – ray Jan 07 '19 at 11:07
-
Sorry You're right I have to acclamate to stackoverflow protocol, it's just that the question is a general how to, and I don't know why this original question and our answers and comments are in duplicate Am I making some mistake when answering? – stuckonrails Jan 07 '19 at 12:00
-
If question is general and explanation is too long, we flag question for reason "too broad" – ray Jan 07 '19 at 12:10
-
I didn't read his question right the first time I realize now that he said he wants to use name instead of id as a primary key in one of his tables – stuckonrails Jan 07 '19 at 12:14