Skip to content

Commit

Permalink
Make use of confirmed scope
Browse files Browse the repository at this point in the history
Use confirmed scope for finding user by slug so there is no need
checking the user record directly
  • Loading branch information
kinsomicrote authored and martinemde committed Nov 14, 2024
1 parent 83701b1 commit b965af5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ProfilesController < ApplicationController
before_action :disable_cache, only: :edit

def show
@user = User.find_by_slug!(params[:id])
return render_not_found unless @user.email_confirmed?
@user = User.confirmed.find_by_slug!(params[:id])
return render_not_found unless @user
@rubygems = @user.rubygems_downloaded.includes(%i[latest_version gem_download]).strict_loading
end

Expand Down
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class User < ApplicationRecord
scope :not_deleted, -> { kept }
scope :deleted, -> { with_discarded.discarded }
scope :with_deleted, -> { with_discarded }
scope :confirmed, -> { where(email_confirmed: true) }

has_many :ownerships, -> { confirmed }, dependent: :destroy, inverse_of: :user

Expand Down

0 comments on commit b965af5

Please sign in to comment.