New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems upgrading to 0.9.29 and dependencies #556
Comments
Excellent question, perhaps you aren't missing anything and the post is incorrect which I apologize for. I'm curious what if you were to try it on the |
Adding the lines to the However... 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:
I get 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. |
@DAddYE Thoughts on how he can achieve this in 0.9.29? Considering we removed custom_dependencies? |
@simonhambly why you can't simply do that: class MyApp < Padrino::Application
dependencies << Padrino.root("app/lib/uploader.rb")
load_paths << ["app/lib/*.rb"]
end |
Oh if that worked, even better I can tweak the blog post. Let me know @simonhambly |
@nesquena - no joy. Adding @DAddYE's suggestion to to MyApp doesn't work - still get 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. |
@DAddYE This seems to be a real problem no? We need a way to recommend people to require deps or what do you recommend? |
* Enhancement for #556 now is possible to add custom prerequisites to our app
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:
ExamplesMyApp.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. |
@simonhambly Can you confirm that the prerequisites method does properly load files now? |
@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. |
Ok thanks simon, we will tweak the carrierwave plugin to fix that issue and update the bleeding edge guide. |
@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. |
@nesquena I made the changes here: padrino/padrino-recipes@4bdb8c5. I'll check out to see if there are any other issues that arise from latest changes but that should cover them. |
Ah great thanks, I will review the recipes a bit later but will assume they are taken care of now. |
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?
The text was updated successfully, but these errors were encountered: