Favor destroy_by over where.first&.destroy (#15868)
* Favor `destroy_by` over `where.first&.destroy` We can use [ActiveRecord::Relation.destroy_by][1] instead of the method chain. [1]:https://api.rubyonrails.org/classes/ActiveRecord/Relation.html#method-i-destroy_by * Restoring custom behavior Those constants are not ActiveRecord::Base objects, so don't implement the method.
This commit is contained in:
parent
6d37f4303c
commit
c7902a3261
1 changed files with 1 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ class ProfilePinsController < ApplicationController
|
|||
|
||||
def update
|
||||
# for removing pinnable
|
||||
current_user.profile_pins.where(id: params[:id]).first&.destroy
|
||||
current_user.profile_pins.destroy_by(id: params[:id])
|
||||
bust_user_profile
|
||||
flash[:pins_success] = "🗑 Pin removed"
|
||||
redirect_back(fallback_location: "/dashboard")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue