0

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
codeObserver
  • 6,521
  • 16
  • 76
  • 121
  • And that's when you will use `rolify` right. I could see that you have it right there… https://github.com/EppO/rolify – j03w Aug 26 '13 at 08:09
  • @j03w Thanks for checking. Can you please explain a bit more ? I am new to Rails in general so may be I am missing something very obvious . Also was your response to issue 1 or 2 in my question ? Thanks for your help – codeObserver Aug 26 '13 at 20:56
  • I want to help you but I really don't have enough time right now sorry… look at this one might help give you some idea http://stackoverflow.com/questions/17602549/rails-devise-rolify-collection-of-employee-with-a-role – j03w Aug 27 '13 at 14:03

0 Answers0