Jason, The initializer is the recommended place for that kind of work to be done. If you keep it in initializers then you can perform a Rails upgrade and not worry about environment.rb being overwritten. Boils down to how you want to maintain your application. Personally, I like seeing a sequel.rb initializer and knowing that I can just change that and not sift through a bunch of other config code. I do the same for jdbc information, application configuration that isn't environment dependent and more.
Don On Jan 12, 2011, at 11:19 AM, Jason Thomas wrote: > I created a file called connect_sequel.rb under config/initializers > with the following code: > > require 'sequel' > DB = Sequel.connect(YAML.load(File.read(File.join(::Rails.root,'config/ > database.yml')))[::Rails.env]) > > That seems to work well. I had previously put it in config/ > environment.rb right before the call to Application.initialize! which > also seemed to work but maybe isn't the best place? > > > On Jan 12, 12:06 pm, Don Morrison <[email protected]> wrote: >> Jason, >> >> Best place is in an initializer. >> >> Don >> >> On Jan 12, 2011, at 10:51 AM, Jason Thomas wrote: >> >> >> >> >> >> >> >>> Where is the recommended place to initialize the Sequel database >>> connection in a Rails app? Initially I was doing it in the model but >>> once you have more than one model that doesn't make sense. Basically >>> where do I put this line: >> >>> DB = Sequel.connect(YAML.load(File.read(File.join(::Rails.root,'config/ >>> database.yml')))[::Rails.env]) >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "sequel-talk" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group >>> athttp://groups.google.com/group/sequel-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
