Closed andrewhavens closed 11 years ago
This could be related to #24. I'll look into it.
What's strange is that sprockets doesn't complain about jquery or jquery_ujs. I looked at the source in the jquery-rails gem and its approach looks pretty much identical, so I don't know why it's not working. FYI: I have also bundled/restarted multiple times so I know that's not the problem.
Actually...it looks like jQuery suffers from the same problem when you remove it from the main app's Gemfile. I'm starting to think this is a problem with Rails/Bundler not requiring my Gem's dependencies. I bet if I explicitly require jquery-rails and backbone-on-rails somewhere before sprockets tries to resolve them, it will work...
Yep, that did the trick. I require jquery-rails
and backbone-on-rails
in my gem's main lib file (since the main rails app will have this in its Gemfile, which will automatically get required) and it works. Feel free to close this or add some documentation or some engine specific code if you'd like.
I added backbone-on-rails as a dependency in my gemspec, but when my engine's javascript manifest tries to require underscore, it fails to find it. As far as I understand, backbone-on-rails is a rails engine itself and provides underscore and backbone through its vendor directory which is automatically loaded as part of the asset pipeline. This has worked well for me in normal Rails apps, but now I'm trying to develop a Rails engine which depends on backbone, and am having trouble trying to get this working correctly. I didn't actually try the install generator because I wasn't sure that it would work, so I copied all the asset directories from another project where I had it working.
Is there something else that I need to do in order to load underscore and backbone besides adding backbone-on-rails as a gem dependency?