Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Problems upgrading to 0.9.29 and dependencies #556
I'm upgrading from 0.9.28 (previously upgrading from 0.9.23) and having some problems loading dependencies. I've followed the instructions on the 0.9.29 blog post about adding dependencies.
In the MyApp.dependencies line I've assumed that MyApp is the application name... so have replaced with my app name (DemoProject). When I run padrino console... I get an "uninitialized constant DemoProject (NameError)"
What am I missing?
Adding the lines to the
Being able to add the statements to the either of the hooks doesn't solve the underlying problem: that files in the app/lib folder aren't being autoloaded.
If you create demo_project as:
and configure load_paths/dependencies by:
# config/boot.rb require Padrino.root("app/app.rb") Padrino.before_load do DemoProject.load_paths << ["app/lib/*.rb"] DemoProject.dependencies << Padrino.root("app/lib/uploader.rb") end
then load the app via:
In 0.9.28 and below (at least until 0.9.23) using the following worked and lib files in
# config/boot.rb Padrino.custom_dependencies(Padrino.root("app/lib/uploader.rb"))
Is there something else I need to do to get app/lib/*.rb files autoloading?
p.s. I'm using multiple apps in a project and want to keep app specific lib files with the appropriate app (in app/lib, app2/lib etc) - that's why I want to move the carrierwave uploader to app/lib.
btw can work around by explicitly requiring the app/lib/uploader.rb file in models/upload.rb works - put kind of defeats auto loading...
Also autoloading works if leave uploader as
Yes I see that as well, it has to do with order of operations I think, the dependencies/load_paths are being added too late in the loading process. @DAddYE Do you have any other approach for them to try? Hopefully there is a workable solution. If not, we will investigate, fix this and release a new patch ASAP. Thanks for bringing this to our attention.
Fixed, from our docs:
An array of file to load before your app.rb, basically are files wich our app depends on.
By default we look for files:
MyApp.prerequisites << Padrino.root('my_app', 'custom_model.rb')
Btw as said we load all deps under app_name/lib/*/.rb so I think is no more necessary.
@nesquena, just had chance to test - the uploader in app/lib is correctly loaded now using the latest code.
Incidently had some issues with carrierwave plugin - it didn't seem to create the upload model in the correct place. Instead it created it as
To get the plugin created I had to run:
Then I could test.
Not sure whether this is plugin generator issue or the carrierwave plugin itself.
One last thing on the "Padrino Guides - The Bleeding Edge" instructions... tweaking the version no (appending "-dev") means
no longer works.
When I ran
I got an "Malformed version number string 0.9.29-dev (ArgumentError)" thrown. So the Bleeding Edge guide may need updating.
@achiu Can you update the plugins? https://github.com/padrino/padrino-recipes/blob/master/plugins/carrierwave_plugin.rb seems to specify app/models but your recent changes to move everything into 'models' by default probably broke several plugins.