tansengming / stripe-rails

A Rails Engine for integrating with Stripe
MIT License
753 stars 123 forks source link

Don't assume sprockets are loaded #150

Closed manusajith closed 5 years ago

manusajith commented 5 years ago

In the initialise step here it is assuming that the sprockets are loaded. This would raise an error and will not allow to boot the app if sprockets are not loaded/used.

Adding a guard clause to make sure it's not invoked if sprockets are not used would be helpful.

# lib/stripe/engine.rb

...

initializer 'stripe.assets.precompile' do |app|
  if !::Rails.env.test? && app.config.respond_to?(:assets)
    app.config.assets.precompile += %w( stripe_elements.js stripe_elements.css )
  end
end

...
IlkhamGaysin commented 5 years ago

+1

tansengming commented 5 years ago

I have this up on https://github.com/tansengming/stripe-rails/pull/151 and will release it once it's green. Good catch.