Skip to content

Instantly share code, notes, and snippets.

@universal
Forked from pluralism/gist:9325799
Created March 3, 2014 14:20
Show Gist options
  • Save universal/9325858 to your computer and use it in GitHub Desktop.
Save universal/9325858 to your computer and use it in GitHub Desktop.
class Admin < User
has_one :user, :as => :userable
attr_accessible :user
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :name, :email, :password, :password_confirmation, :role
belongs_to :userable, :polymorphic => true
# Checks if a given user has "role" permission
def is?(role)
self.role == role.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment