Sha256: 77e5867473c3f59646fbd2a0afa5987483de6568f95964675450192b98231c8f
Contents?: true
Size: 977 Bytes
Versions: 11
Compression:
Stored size: 977 Bytes
Contents
module JqueryCdn # Tell Ruby on Rails to add vendor/assets to Assets Pipeline class Engine < ::Rails::Engine end module RailsHelpers # Return <script> tags to add jQuery in Rails def include_jquery(options = { }) options = { env: Rails.env.to_sym }.merge(options) JqueryCdn.local_url = proc { javascript_path("jquery.js") } JqueryCdn.include_jquery(options).html_safe end end class Railtie < Rails::Railtie initializer 'jquery-cdn' do |app| # Ensure that we before jquery-rails to fix name conflict root = Pathname(__FILE__).dirname.join('../..').expand_path vendor = root.join('vendor/assets/javascripts') app.config.assets.prepend_path(vendor) # Add include_jquery helper ActiveSupport.on_load(:action_view) do include JqueryCdn::RailsHelpers end # Precompile all JS/CSS in root of app assets dirs. app.config.assets.precompile << 'jquery.js' end end end
Version data entries
11 entries across 11 versions & 1 rubygems