Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/20240909-user-validation-error' …
Browse files Browse the repository at this point in the history
…into 20241126-maintenance-release
  • Loading branch information
Dennis Deli authored and Dennis Deli committed Nov 27, 2024
2 parents 0f16c84 + 6d02216 commit e167b53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ There are 3 containers created: **web**, **db** and **mailcatcher**

# Access the front end web app in DEVELOPMENT

By default, the application will listen on port 3006 and runs with RAILS_ENV=development.
By default, the application will listen on port 3006 and runs with RAILS_ENV=development.

To access the application in Chrome browser, you will need to add the ModHeader extension to your Chrome browser.

Once the extension has been activated, you can add the following header to the site http://localhost:3006/. This will enable you to login as **manager** user.
Once the extension has been activated, you can add the following header to the site http://localhost:3006/. This will enable you to login as **manager** user.

Header: PYORK_USER
Expand Down
8 changes: 4 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class User < ApplicationRecord
belongs_to :location

## VALIDATIONS
validates_presence_of :name, :email, :uid, :user_type, :role
validates :email, presence: true, uniqueness: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }, if: :new_record?
validates :uid, uniqueness: true, if: :new_record?
validates_presence_of :name, :email, :uid, :user_type
validates_presence_of :role, if: :admin?
validates_presence_of :department, :phone, :office, unless: proc { |u| u.admin? }
validates_presence_of :location, if: proc { |u| u.admin? }
validates :email, presence: true, uniqueness: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }

validates_uniqueness_of :uid

## SCOPES
scope :admin, -> { where(admin: true) }
Expand Down

0 comments on commit e167b53

Please sign in to comment.