remove remaining AR find_by_x finders

- most of them were removed by @myabc in the rails4 branch
- some where reintroduced due to parallel development to that branch
- still some occurences left that will hit custom implementations
pull/3400/head
Jan Sandbrink 9 years ago
parent 37268897da
commit dfb9a5cd20
  1. 2
      app/controllers/work_packages/auto_completes_controller.rb
  2. 2
      app/models/journal/aggregated_journal.rb
  3. 4
      app/services/move_work_package_service.rb
  4. 4
      app/workers/deliver_work_package_notification_job.rb
  5. 2
      app/workers/enqueue_work_package_notification_job.rb
  6. 4
      db/seeds/builtin_roles.rb

@ -73,7 +73,7 @@ class WorkPackages::AutoCompletesController < ApplicationController
def find_project
project_id = (params[:work_package] && params[:work_package][:project_id]) || params[:project_id]
return nil unless project_id
Project.find_by_id(project_id)
Project.find_by(id: project_id)
end
def determine_scope

@ -316,7 +316,7 @@ class Journal::AggregatedJournal
end
def data
@data ||= "Journal::#{journable_type}Journal".constantize.find_by_journal_id(id)
@data ||= "Journal::#{journable_type}Journal".constantize.find_by(journal_id: id)
end
private

@ -167,14 +167,14 @@ class MoveWorkPackageService
new_category = if work_package.category.nil?
nil
else
new_project.categories.find_by_name(work_package.category.name)
new_project.categories.find_by(name: work_package.category.name)
end
work_package.category = new_category
end
def assign_status_or_default(work_package, status_id)
status = if status_id.present?
Status.find_by_id(status_id)
Status.find_by(id: status_id)
else
self.work_package.status
end

@ -69,7 +69,7 @@ class DeliverWorkPackageNotificationJob
end
def raw_journal
@raw_journal ||= Journal.find_by_id(@journal_id)
@raw_journal ||= Journal.find_by(id: @journal_id)
end
def work_package
@ -77,6 +77,6 @@ class DeliverWorkPackageNotificationJob
end
def author
@author ||= User.find_by_id(@author_id) || DeletedUser.first
@author ||= User.find_by(id: @author_id) || DeletedUser.first
end
end

@ -68,7 +68,7 @@ class EnqueueWorkPackageNotificationJob
end
def raw_journal
@raw_journal ||= Journal.find_by_id(@journal_id)
@raw_journal ||= Journal.find_by(id: @journal_id)
end
def work_package

@ -27,7 +27,7 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
if Role.find_by_builtin(Role::BUILTIN_NON_MEMBER).nil?
if Role.find_by(builtin: Role::BUILTIN_NON_MEMBER).nil?
role = Role.new
role.name = 'Non member'
@ -36,7 +36,7 @@ if Role.find_by_builtin(Role::BUILTIN_NON_MEMBER).nil?
role.save!
end
if Role.find_by_builtin(Role::BUILTIN_ANONYMOUS).nil?
if Role.find_by(builtin: Role::BUILTIN_ANONYMOUS).nil?
role = Role.new
role.name = 'Anonymous'

Loading…
Cancel
Save