Perform the where(...).first to find_by(...) refactoring.

This refactoring was automated using the command: bundle exec "ruby refactorings/where_dot_first_to_find_by/app.rb"
This commit is contained in:
Louis Rose
2014-05-06 14:41:59 +01:00
parent f1369e4503
commit 1574485443
104 changed files with 204 additions and 213 deletions

View File

@ -6,7 +6,7 @@ class InvitesController < ApplicationController
before_filter :ensure_logged_in, only: [:destroy, :create]
def show
invite = Invite.where(invite_key: params[:id]).first
invite = Invite.find_by(invite_key: params[:id])
if invite.present?
user = invite.redeem
@ -42,7 +42,7 @@ class InvitesController < ApplicationController
def destroy
params.require(:email)
invite = Invite.where(invited_by_id: current_user.id, email: params[:email]).first
invite = Invite.find_by(invited_by_id: current_user.id, email: params[:email])
raise Discourse::InvalidParameters.new(:email) if invite.blank?
invite.trash!(current_user)