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

wants to merge 1 commit into


None yet

2 participants


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.

indirect commented Jun 9, 2011

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.

@indirect indirect closed this Jun 9, 2011

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.


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