improvements to pool add

This commit is contained in:
albert
2013-02-17 23:39:43 -05:00
parent 2af59642f6
commit ae082cda48
4 changed files with 26 additions and 10 deletions

View File

@@ -25,6 +25,7 @@ class Pool < ActiveRecord::Base
return q if params.blank?
if params[:name_matches].present?
params[:name_matches] += "*" unless params[:name_matches] =~ /\*/
q = q.where("name like ? escape E'\\\\'", params[:name_matches].to_escaped_for_sql_like)
end
@@ -64,6 +65,10 @@ class Pool < ActiveRecord::Base
select_value_sql("SELECT name FROM pools WHERE id = ?", id)
end
def self.options
select_all_sql("SELECT id, name FROM pools WHERE is_active = true AND is_deleted = false ORDER BY name LIMIT 100").map {|x| [x["name"], x["id"]]}
end
def self.create_anonymous
Pool.new do |pool|
pool.name = "TEMP:#{Time.now.to_f}.#{rand(1_000_000)}"