class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me has_one :user_has_role has_one :role, :through => :user_has_role belongs_to :user_group belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id' end