Closed bricker closed 11 years ago
Hi Bryan
I realise this ticket's been sitting around for a little while. I'm not entirely sure what the cause is, but jquery/rails
does define Jquery::Rails::PROTOTYPE_JS
(though not Jquery::Rails::Railtie::PROTOTYPE_JS
- but wouldn't Ruby's constant hierarchy pick up on that?). It's a little odd, and there's been no patches to the jquery-rails gem's source code nor any issues logged that would indicate others are seeing this problem elsewhere.
I don't suppose you've made any progress on this since logging the issue?
To work around this, I added jquery-rails to my app's Gemfile, and removed it from the engine all together. Not really a solution but I can run the tests and the app now.
Ah, good to know you got a solution figured out. I'm going to close this, but if anyone hits the same issue and wants to discuss how to work through it, feel free to comment here.
I don't know if it's useful, but I've found out why it happens. The gem 'jquery-rails' uses a 'before configuration' block to initialize some things. Normally, in application.rb
, all railties are loaded before your <ProjectName>::Application
class is created, so that these before configuration blocks are run at the right time.
Combustion seems to create class Combustion::Application
immediately when file 'combustion' is required, which means that any subsequent 'before configuration' blocks are run immediately when they are defined. In the case of jquery-rails, this is too soon, as this constant has not been set yet.
My workaround was to use the following:
require 'rails'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
require 'jquery/rails'
require 'combustion'
Combustion.initialize!
Sorry about throwing a bunch of code at you...
spec_helper.rb:
Gemfile:
gemspec:
And I have some requires at the top of my
engine.rb
:So basically when I run
bundle exec rake
, I get:If I remove
require 'jquery-rails'
fromengine.rb
, the tests run fine but then my app won't load (sprockets complains, "can't find file 'jquery'").