Guest User

Untitled

a guest
Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class Case < ApplicationRecord
  2. resourcify
  3. end
  4.  
  5. class User < ApplicationRecord
  6. rolify strict: true
  7. # Include default devise modules. Others available are:
  8. # :confirmable, :lockable, :timeoutable and :omniauthable
  9. devise :database_authenticatable, :registerable,
  10. :recoverable, :rememberable, :trackable, :validatable
  11.  
  12. belongs_to :role
  13.  
  14. after_create :assign_default_role
  15. def assign_default_role
  16. self.add_role "newuser" if self.roles.blank?
  17. end
  18.  
  19. end
  20.  
  21. Case.first.roles.where(name: "facilitator").first
  22.  
  23. Case.first.find_roles(:facilitator)
Add Comment
Please, Sign In to add comment