On Wednesday, July 16, 2014 11:20:46 PM UTC-7, Damjan Rems wrote: > > I would like to use sequel with rails with just single (generic) defined > model: > > So far I have this class defined inside models directory. > > class Oracle > def self.db > c = Rails.application.config.database_configuration['oracle'] > Sequel.connect(:adapter=>'oracle', :database=>c['database'], > :user=>c['username'], :password=>c['password']) > end > end > > Which can be called like: > data = Oracle.db.from(:partner).where(id: someid).all > > What bothers me is how to make this work without .db method beeing used. > Just the way it is used when model is defined. > data = Oracle.from(:partner).where(id: someid).all > As I stated when I replied to your GitHub issue, you can probably just do:
c = Rails.application.config.database_configuration['oracle'] Oracle = Sequel.connect(:adapter=>'oracle', :database=>c['database'], :user=>c['username'], :password=>c['password']) That way your Database instance is just made available in the Oracle constant. If you are not setting up the database connection yourself, but relying on an integration library such assequel-rails to do so for you, you should ask them. Most likely if they are setting up the database connection, you can access it in the Sequel::DATABASES array. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
