Created
December 6, 2012 16:38
-
-
Save mauriciopasquier/4225871 to your computer and use it in GitHub Desktop.
rolify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# User model | |
class Usuario < ActiveRecord::Base | |
rolify :role_cname => 'Rol' | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable | |
end | |
# Role model | |
class Rol < ActiveRecord::Base | |
has_and_belongs_to_many :usuarios, join_table: :usuarios_roles | |
belongs_to :resource, :polymorphic => true | |
scopify | |
end | |
# Some resource | |
class Texto < ActiveRecord::Base | |
resourcify role_cname: 'Rol' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment