Merge pull request #983 from warpc/977-ActiveRecord-StatementInvalid

refs #977: update "scope" for Platform and Repository models to fix ActiveRecord::StatementInvalid: PG::Error
This commit is contained in:
Vladimir Sharshov 2013-02-28 07:07:26 -08:00
commit 66bbbb08e7
2 changed files with 3 additions and 3 deletions

View File

@ -38,8 +38,8 @@ class Platform < ActiveRecord::Base
after_create lambda { symlink_directory unless hidden? } after_create lambda { symlink_directory unless hidden? }
after_destroy lambda { remove_symlink_directory unless hidden? } after_destroy lambda { remove_symlink_directory unless hidden? }
scope :search_order, order("CHAR_LENGTH(name) ASC") scope :search_order, order("CHAR_LENGTH(platforms.name) ASC")
scope :search, lambda {|q| where("name ILIKE ?", "%#{q.to_s.strip}%")} scope :search, lambda {|q| where("platforms.name ILIKE ?", "%#{q.to_s.strip}%")}
scope :by_visibilities, lambda {|v| where(:visibility => v)} scope :by_visibilities, lambda {|v| where(:visibility => v)}
scope :opened, where(:visibility => 'open') scope :opened, where(:visibility => 'open')
scope :hidden, where(:visibility => 'hidden') scope :hidden, where(:visibility => 'hidden')

View File

@ -15,7 +15,7 @@ class Repository < ActiveRecord::Base
validates :description, :presence => true validates :description, :presence => true
validates :name, :uniqueness => {:scope => :platform_id, :case_sensitive => false}, :presence => true, :format => {:with => /\A[a-z0-9_\-]+\z/} 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]} before_destroy :detele_directory, :unless => lambda {Thread.current[:skip]}