Sha256: cb373dae827dec23e450d8afeb4d8e8cce78b85b6d48ebac069049db12794ca5

Contents?: true

Size: 318 Bytes

Versions: 24

Compression:

Stored size: 318 Bytes

Contents

class User < ApplicationRecord
  after_initialize :set_default_role, if: :new_record?

  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable

  has_many :posts

  enum role: { user: 0, moderator: 1, admin: 9 }

  private

  def set_default_role
    self.role ||= :user
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rails_app_generator-0.2.30 after_templates/addons/pretender/app/models/user.rb
rails_app_generator-0.2.29 after_templates/addons/pretender/app/models/user.rb
rails_app_generator-0.2.28 after_templates/addons/pretender/app/models/user.rb
rails_app_generator-0.2.27 after_templates/addons/pretender/app/models/user.rb