Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

javascript_expansions[:defaults] in config/application.rb overwrite amendments made by railtie.rb #4

Closed
wants to merge 1 commit into from

2 participants

John Plummer André Arko
John Plummer

Changed railtie to amend configuration after Rails has parsed config/application.rb.
Tested with 3.0.7.
This will adversely affect projects where the jquery scripts have been added in the application.rb, any scripts added to default there will be added in addition to the scripts added by the railtie. Hopefully a reasonable trade off as currently the railtie is ignored if javascript_expansions[:defaults] is set in application.rb.

André Arko
Owner

Thanks for the patch! In this particular case, the currect behaviour is deliberate. If you want to override the defaults, you can (by setting them with =). If you want to add to the defaults, you also can (by adding new items with <<). If the railtie changed things after application.rb, it would be impossible to override by the user developing their rails app.

André Arko indirect closed this
John Plummer

Of course, didn't think of that. Is there anyway to get application.js to load before jquery_ujs.js?

Also as posted here running rails new app -J then rails g jquery:install -ui will not work until you amend config/application.rb. May be worth adding an explanation to the readme although it looks like this will go away in 3.1?

Anyhow, thanks for your time and explanation, I like the railtie solution, very clean.

André Arko
Owner

The javascript defaults is an array. All you have to do is change it to the order you want. You can simply call unshift("application.js") to put that at the front.

The issue with -J is a problem with Rails, yes. It's fixed in 3.1, and the README for this project doesn't tell you to use -J. Maybe I should add a note explicitly instructing people to NOT use -J. :\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 9, 2011
  1. John Plummer
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/jquery/rails/railtie.rb
2  lib/jquery/rails/railtie.rb
View
@@ -3,7 +3,7 @@ module Jquery
module Rails
class Railtie < ::Rails::Railtie
- config.before_configuration do
+ config.before_initialize do
require "jquery/assert_select" if ::Rails.env.test?
if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist?
Something went wrong with that request. Please try again.