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:
commit
66bbbb08e7
|
@ -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')
|
||||||
|
|
|
@ -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]}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue