blob: 5f081af4f17aa2cc0c31b7e5ccf9d73ba67d0462 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#gem "activerecord", "= 2.3.8"
#gem "ar-extensions", "= 0.9.2"
['rubygems', 'logger', 'active_record', 'opentox-ruby' ].each do |g| #'ar-extensions',
require g
end
unless ActiveRecord::Base.connected?
ActiveRecord::Base.establish_connection(
:adapter => CONFIG[:database][:adapter],
:host => CONFIG[:database][:host],
:database => CONFIG[:database][:database],
:username => CONFIG[:database][:username],
:password => CONFIG[:database][:password]
)
ActiveRecord::Base.logger = Logger.new("/dev/null")
end
class ActiveRecord::Base
def self.find_like(filter_params)
raise "find like removed"
#puts "params before "+filter_params.inspect
filter_params.keys.each do |k|
key = k.to_s
unless self.column_names.include?(key)
key = key.from_rdf_format
unless self.column_names.include?(key)
key = key+"_uri"
unless self.column_names.include?(key)
key = key+"s"
unless self.column_names.include?(key)
err = "no attribute found: '"+k.to_s+"'"
# if $sinatra
# $sinatra.raise OpenTox::BadRequestError.newerr
# else
raise err
# end
end
end
end
end
filter_params[key+"_like"] = filter_params.delete(k)
end
#puts "params after "+filter_params.inspect
self.find(:all, :conditions => filter_params)
end
end
|