# module RoleBasedSecurity module ModelAdditions # ::Rails.logger.error("...") # # Parameter role is a string rather than object, for example moderator or admin def has_role?(role) user_roles = UserRole.find :all, :conditions => ["user_id = ? ", self.id] return false if user_roles.nil? || (user_roles.size() == 0) user_roles.each do |user_role| next if user_role.role.code != role return true end false end end end