lib/aegis/has_role.rb in aegis-1.1.6 vs lib/aegis/has_role.rb in aegis-1.1.7

- old
+ new

@@ -1,11 +1,11 @@ module Aegis module HasRole def validates_role_name(options = {}) validates_each :role_name do |record, attr, value| - options[:message] ||= ActiveRecord::Errors.default_error_messages[:inclusion] + options[:message] ||= I18n.translate('activerecord.errors.messages.inclusion') role = ::Permissions.find_role_by_name(value) record.errors.add attr, options[:message] if role.nil? end end @@ -94,11 +94,11 @@ end alias_method_chain :respond_to?, :aegis_permissions def set_default_aegis_role_name - if new_record? - self.aegis_role_name ||= self.class.aegis_default_role_name + if new_record? && self.aegis_role_name.blank? + self.aegis_role_name = self.class.aegis_default_role_name end end end