Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
23 changes: 11 additions & 12 deletions lib/jquery/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't undersell yourself! You also made this work at all, since the file is named jquery_ujs, and not rails. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, or I could have misread the diff. Still, thanks for the patch! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just condensing the logic from 2 lines (previously 20 & 21) into 1 line (20).

end
end
end
Expand Down