Which is the right path to place an initializer in a Padrino sub application

1k Views Asked by At

I'm working with OmniAuth-Facebook and initializing it in mysubapp/app.rb:

require 'omniauth-facebook' 

class MySubApp < Padrino::Application
  register Padrino::Rendering
  register Padrino::Mailer
  register Padrino::Helpers

  enable :sessions

  SCOPE = 'email,read_stream'
  ENV['APP_ID'] = '111111111111111'
  ENV['APP_SECRET'] = '11111111111111111111111111111111'

  use OmniAuth::Builder do
    provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], :scope => SCOPE
  end
end 

I just want to know if this is the way you should work with Padrino. Is this the right place to put my initializers or, maybe, you can create an specific sub-application config.ru?

1

There are 1 best solutions below

0
On

Placing code into boot.rb for multi-app deployments, or in the apps app.rb is the correct place to put things.

If you like things looking cleaner you could create a new config/initializers directory then add the following to boot.rb

Padrino.require_dependencies "#{Padrino.root}/config/initializers/**/*.rb"

Here is the Padrino guide for Special Folders which as a little bit more about loading or requiring additional paths.