From b422f60bd45edaa20ec8caecba2a901dbde8853d Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 28 Feb 2013 18:58:16 +0400 Subject: [PATCH] #977: update "scope" for Pletform and Repository models --- app/models/platform.rb | 4 ++-- app/models/repository.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/platform.rb b/app/models/platform.rb index 7f94a84e0..a97d6647a 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -38,8 +38,8 @@ class Platform < ActiveRecord::Base after_create lambda { symlink_directory unless hidden? } after_destroy lambda { remove_symlink_directory unless hidden? } - scope :search_order, order("CHAR_LENGTH(name) ASC") - scope :search, lambda {|q| where("name ILIKE ?", "%#{q.to_s.strip}%")} + scope :search_order, order("CHAR_LENGTH(platforms.name) ASC") + scope :search, lambda {|q| where("platforms.name ILIKE ?", "%#{q.to_s.strip}%")} scope :by_visibilities, lambda {|v| where(:visibility => v)} scope :opened, where(:visibility => 'open') scope :hidden, where(:visibility => 'hidden') diff --git a/app/models/repository.rb b/app/models/repository.rb index 7abee60a5..219f107ab 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -15,7 +15,7 @@ class Repository < ActiveRecord::Base validates :description, :presence => true validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => {:with => /\A[a-z0-9_\-]+\z/} - scope :recent, order("name ASC") + scope :recent, order("repositories.name ASC") before_destroy :detele_directory, :unless => lambda {Thread.current[:skip]}