padrino-framework: prerequisites doesn't work

Hi,

I am trying to add some more directories to my auto load path by doing this

Padrino.before_load do
  MyApp.prerequisites << Padrino.root("app/presenters/*.rb")
end

This is the way specified in the docs. But when I try and do this I get the following error

vendor/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing': uninitialized constant Object::MyApp (NameError)

And even when I do this after the

Padrino.load!

command, and do a reload, the files in this directory are not loaded.

Is there something that I am doing wrong here?

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

I think you should use dependencies:

Padrino.before_load do
  MyApp.dependencies << Padrino.root("app/presenters/*.rb")
end

prerequisites are deps that prevent app to load correctly, dependencies are files used in app.

If you need it globally you can also use:

Padrino.dependency_paths << Padrino.root("app/presenters/*.rb")

Finally if you want to add a path to your Padrino env you should use:

Padrino.set_load_paths(Padrino.root('app/presenters'))

# somewhere
require 'my_presenter'