From decd4bf293999422c34c0db7ef798f4a4a890464 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Fri, 31 Aug 2012 21:47:52 +0400 Subject: [PATCH] [issue #620] Removed scope from BuildList::Package && small refactoring. --- app/controllers/platforms/maintainers_controller.rb | 2 +- app/controllers/projects/projects_controller.rb | 2 +- app/models/build_list/package.rb | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 414c37612..386e48ae4 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -8,7 +8,7 @@ class Platforms::MaintainersController < ApplicationController @maintainers = BuildList::Package.actual.by_platform(@platform) .order('lower(name) ASC, length(name) ASC') .includes(:project) - @maintainers = @maintainers.find_by_name(params[:q]) if params[:q].present? + @maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present? @maintainers = @maintainers.paginate(:page => params[:page]) end diff --git a/app/controllers/projects/projects_controller.rb b/app/controllers/projects/projects_controller.rb index 0720e5e8d..740d62976 100644 --- a/app/controllers/projects/projects_controller.rb +++ b/app/controllers/projects/projects_controller.rb @@ -39,7 +39,7 @@ class Projects::ProjectsController < Projects::BaseController end def update - params[:project].delete(:maintainer_id) unless params[:project][:maintainer_id].present? + params[:project].delete(:maintainer_id) if params[:project][:maintainer_id].blank? if @project.update_attributes(params[:project]) flash[:notice] = t('flash.project.saved') redirect_to @project diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 795005c0a..ce894412b 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -16,7 +16,6 @@ class BuildList::Package < ActiveRecord::Base scope :actual, where(:actual => true) scope :by_platform, lambda {|platform| where(:platform_id => platform) } scope :by_name, lambda {|name| where(:name => name) } - scope :find_by_name, lambda {|name| where('name ILIKE ?', "%#{name}%") } scope :by_package_type, lambda {|type| where(:package_type => type) } def assignee