app/models/elabs/user.rb in elabs-3.0.0 vs app/models/elabs/user.rb in elabs-4.0.0

- old
+ new

@@ -1,9 +1,13 @@ module Elabs class User < ApplicationRecord self.table_name = 'users' + include Elabs::Concerns::Sluggable + SLUGGABLE_FIELD = nil + SLUG_FIELD = :username + validates :username, presence: true, uniqueness: true validates :role, presence: false validate :avatar_format if Elabs.use_avatars # Username should: @@ -23,19 +27,23 @@ has_one_attached :avatar if Elabs.use_avatars scope :admins, -> { where(role: 'admin') } + after_create do + Preference.create! user: self, show_nsfw: false + end + def admin? role == 'admin' end def display_name real_name.present? ? real_name : "@#{username}" end - after_create do - Preference.create! user: self, show_nsfw: false + def to_param + username end private def avatar_format