Created
June 9, 2011 19:48
-
-
Save JohnPlummer/1017551 to your computer and use it in GitHub Desktop.
jquery-rails setting default scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config.action_view.javascript_expansions[:defaults] = %w() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.action_view.javascript_expansions[:defaults] << %w(my_script) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.action_view.javascript_expansions[:defaults] = %w(my_script) << config.action_view.javascript_expansions[:defaults] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure Rails 3.0 to use public/javascripts/jquery et al | |
module Jquery | |
module Rails | |
class Railtie < ::Rails::Railtie | |
config.before_configuration do | |
require "jquery-rails/assert_select_jquery" if ::Rails.env.test? | |
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? | |
else | |
jq_defaults = ::Rails.env.production? ? %w(jquery.min) : %w(jquery) | |
end | |
# Merge the jQuery scripts, remove the Prototype defaults and finally add 'rails' | |
# 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' | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment