Devise: Foreign key columns for roles in user_id

627 Views Asked by At

I used rails composer to create a starter app for my rails project. It is using devise to create and manage roles

I have following roles for my User: Recruiter, Applicant A User can one or both of [Recruiter, Applicant]

I looked at the User model , but it doesnt have any foreign key role_id column. I added that column myself,and I am facing following issues

1] The app only assigns role_id=1 for every user I sign up

2] For user who is both a recruiter and an applicant, would there be 2 roles in User column with different Ids [1 and 2] , how would/should this model be handled.

This is my User model:

class User < ActiveRecord::Base
  rolify
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :role_ids, :as => :admin
  attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :user_id, :role_ids
  validates_presence_of :email

  has_many :applications
  has_many :jobs          
end
0

There are 0 best solutions below