Sha256: 9c535129ea092ad8e6418120032eaff6de40184f4e8cde5f87fbbd4af6049e83
Contents?: true
Size: 786 Bytes
Versions: 6
Compression:
Stored size: 786 Bytes
Contents
validate :username_or_email_exists # Used for validation. Validates whether a username or email exists because one is required. def username_or_email_exists if username.blank? && email.blank? self.errors.add(:email, "or Username is required.") end end # Returns the user's email or username depending on which is set # @return [String] Return username unless it is blank, then return email def display_name return self.username.blank? ? self.email : self.username end class << self # Join to the user role habtm table that restricts output to super admins def superadmins joins("join roles_users on users.id = roles_users.user_id").where("roles_users.role_id = (select id from roles where name = 'SuperAdmin')"); end end
Version data entries
6 entries across 6 versions & 1 rubygems