This issue i' m facing When trying to create a seeds.rb inorder to define roles with rolify gem in rails
Asked
Active
Viewed 734 times
-2
-
it would be helpful to provide your code for User.rb. – Roshan Aug 18 '17 at 11:25
-
user.rb: class User < ActiveRecord::Base rolify rolify :role_cname => 'Usertype' # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :projects, dependent: :destroy end – sowmya Aug 18 '17 at 12:10
-
I think you have to read [how-to-ask](https://stackoverflow.com/help/how-to-ask) article to enhance your knowledge on asking question in stackoverflow. For e.g, source code are to be placed in your question and not in the comment section. – Roshan Aug 18 '17 at 12:23
2 Answers
0
On line 2, change this rolify rolify: role_cname => 'Usertype'
to
rolify :role_cname => 'Usertype'
You have two rolify
on your User.rb, only one is sufficient.

Roshan
- 905
- 9
- 21
0
Observation: As per Rails convention, the constants should contain all Uppercase characters. I see that you have used HABTM_Roles, which is violating the rule.
HABTM_Roles should be written as
HABTM_ROLES
Also please check for any duplicate declaration of the constant exists, as the error says already initialized constant.

harika
- 113
- 10