From 2b1e69a65f3ff6e4ddd5daafd084f31161b3285e Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Mon, 15 Oct 2012 11:23:32 -0400 Subject: [PATCH 1/2] Adjusting CHANGELOG to note results from 6917459662. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6448de5e..0bcdd6cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2.1.4 (unreleased) - Rails 4 compatibility + - Fixed compatibility for Rails 3.0 (or greater with asset pipeline *disabled*) ## 2.1.3 (24 September 2012) From f06344bf3a7e9efc9f22ba5c235abc102b06e899 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Mon, 15 Oct 2012 12:16:55 -0400 Subject: [PATCH 2/2] Adjusting the railtie so that the entire code block only gets loaded if the config.action_view.javascript_expansions option exists (since it does not in Rails 4). --- lib/jquery/rails/railtie.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/jquery/rails/railtie.rb b/lib/jquery/rails/railtie.rb index aad74227..12bec221 100644 --- a/lib/jquery/rails/railtie.rb +++ b/lib/jquery/rails/railtie.rb @@ -4,21 +4,20 @@ module Jquery module Rails class Railtie < ::Rails::Railtie - config.before_configuration do + if config.action_view.javascript_expansions + config.before_configuration do - if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist? - jq_defaults = %w(jquery jquery-ui) - jq_defaults.map!{|a| a + ".min" } if ::Rails.env.production? || ::Rails.env.test? - else - jq_defaults = ::Rails.env.production? || ::Rails.env.test? ? %w(jquery.min) : %w(jquery) - end + if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist? + jq_defaults = %w(jquery jquery-ui) + jq_defaults.map!{|a| a + ".min" } if ::Rails.env.production? || ::Rails.env.test? + else + jq_defaults = ::Rails.env.production? || ::Rails.env.test? ? %w(jquery.min) : %w(jquery) + end - # Merge the jQuery scripts, remove the Prototype defaults and finally add 'jquery_ujs' - # at the end, because load order is important - if config.action_view.javascript_expansions + # Merge the jQuery scripts, remove the Prototype defaults and finally add 'jquery_ujs' + # at the end, because load order is important config.action_view.javascript_expansions[:defaults] -= PROTOTYPE_JS + ['rails'] - config.action_view.javascript_expansions[:defaults] |= jq_defaults - config.action_view.javascript_expansions[:defaults] << 'jquery_ujs' + config.action_view.javascript_expansions[:defaults] |= jq_defaults + ['jquery_ujs'] end end end