Skip to content

Instantly share code, notes, and snippets.

@jonbuda
Created February 27, 2011 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonbuda/846589 to your computer and use it in GitHub Desktop.
Save jonbuda/846589 to your computer and use it in GitHub Desktop.
Simple Rake task for Rails3 to install/update to the latest version of jQuery and the rails.js UJS driver
namespace :jquery do
desc "Installs the latest version of jQuery and the rails.js UJS jQuery Adapter"
task :install => :update do
puts "Installed jQuery and the rails.js UJS jQuery Adapter"
puts %Q{
******************************************************************************
You can update your javascript defaults in Rails3 with the following:
in application.rb, add:
config.action_view.javascript_expansions[:defaults] = %w(jquery.min rails)
******************************************************************************
}
end
desc "Updates to the latest version of jQuery and the rails.js UJS jQuery Adapter"
task :update do
version = ENV['JQUERY_VERSION'] || nil
jquery = open("http://code.jquery.com/jquery#{version ? "-#{version}" : ""}.min.js")
ujs = open('https://github.com/rails/jquery-ujs/raw/master/src/rails.js')
puts "\n"
puts "Updating jQuery..."
File.open(File.join(Rails.root, 'public/javascripts/jquery.min.js'), 'w+') do |f|
f << jquery.read
end
puts "Updating jQuery UJS (from Github HEAD)..."
File.open(File.join(Rails.root, 'public/javascripts/rails.js'), 'w+') do |f|
f << ujs.read
end
puts "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment