diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-03-11 14:29:13 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-03-11 14:29:13 +0100 |
commit | 96d500e9691eedbfdd57ec35a2572b59641377f3 (patch) | |
tree | 211391f36e269bf36ca09d54aab0d93ababfa412 /lib/active_record_setup.rb | |
parent | 5f243f1e9e0a8e12cd8a2267bcec3140d21bf445 (diff) | |
parent | 7cd9c9656010b88b7e41477e1571cb7e722650c4 (diff) |
Merge branch 'release/v1.0.1'v1.0.1
Diffstat (limited to 'lib/active_record_setup.rb')
-rwxr-xr-x | lib/active_record_setup.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/active_record_setup.rb b/lib/active_record_setup.rb new file mode 100755 index 0000000..b43e692 --- /dev/null +++ b/lib/active_record_setup.rb @@ -0,0 +1,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.halt 400,err +# 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
\ No newline at end of file |