magick encoding

This commit is contained in:
Nico 2013-01-09 00:03:39 +01:00
parent 400d07c0c1
commit 2e22001662
2 changed files with 2 additions and 31 deletions

View File

@ -9,31 +9,10 @@ class Admin < ActiveRecord::Base
attr_accessor :login attr_accessor :login
# Setup accessible (or protected) attributes for your model # Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name, :firstname, :roles_mask, :roles, :super_admin attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name, :firstname
# attr_accessible :title, :body # attr_accessible :title, :body
ROLES = %w[SuperAdmin]
def super_admin?
true if self.is? :SuperAdmin
end
def roles=(roles)
self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum
end
def roles
ROLES.reject do |r|
((roles_mask || 0) & 2**ROLES.index(r)).zero?
end
end
def is?(role)
roles.include?(role.to_s)
end
protected protected
def self.find_for_database_authentication(warden_conditions) def self.find_for_database_authentication(warden_conditions)

View File

@ -31,14 +31,6 @@
%td= f.text_field :password_confirmation, :class => "inputText" %td= f.text_field :password_confirmation, :class => "inputText"
%tr
%td{:style => "vertical-align:top;"} Roles :
%td
- for role in Admin::ROLES
= check_box_tag "admin[roles][]", role, @admin.roles.include?(role)
=h role.humanize
%br
= hidden_field_tag "admin[roles][]", ""
.actions .actions
%button{:type => "submit"} Sauvegarder %button{:type => "submit"} Sauvegarder