Sha256: 81daf09a15b4c316a773bf3ad54052229a3af1b7f7e530a0d98b585b188b4725

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

class User < ActiveRecord::Base

  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation,:username
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation,:role_ids,:username
  has_and_belongs_to_many :roles
  
  def role #array con los roles del usuario
    roles.map do |role|
      role.name
    end
  end    
  
  def role?(rol) #true si el usuario tiene el rol
    role.include?(rol)
  end
  
  def role_symbols
    roles.map do |role|
      role.name.underscore.to_sym
    end
  end 
  
end

Version data entries

11 entries across 7 versions & 1 rubygems

Version Path
squeezer-0.2.1 lib/generators/squeezer/templates/app/models/user.rb
squeezer-0.2.0 lib/generators/squeezer/templates/app/models/user.rb
squeezer-0.1.11 app/models/user.rb
squeezer-0.1.11 lib/generators/squeezer/templates/app/models/user.rb
squeezer-0.1.7 app/models/user.rb
squeezer-0.1.7 lib/generators/squeezer/templates/app/models/user.rb
squeezer-0.1.6 lib/generators/squeezer/templates/app/models/user.rb
squeezer-0.1.6 app/models/user.rb
squeezer-0.1.5 lib/generators/squeezer/templates/app/models/user.rb
squeezer-0.1.5 app/models/user.rb
squeezer-0.1.4 lib/generators/squeezer/templates/app/models/user.rb