Skip to content

Instantly share code, notes, and snippets.

@mauriciopasquier
Created December 6, 2012 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mauriciopasquier/4225871 to your computer and use it in GitHub Desktop.
Save mauriciopasquier/4225871 to your computer and use it in GitHub Desktop.
rolify
# 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