John Paul Ashenfelter

Blogs are for geeks. Guilty!

John Paul Ashenfelter header image 2

Fix for no expansion found for defaults error in Rails 3.0.4

February 9th, 2011 · 6 Comments · ruby

Just a quick tech tip from our upgrade to Rails 3.0.4 this morning. Started with bundle update, fired up server, hit it with a browser and immediately got:

No expansion found for :defaults

near

<%= javascript_include_tag :defaults %>

After 30s of Googling, realize I hadn’t done a rake rails:update. Personally, I don’t like clobbering my app with unknown changes, so I typically create a new rails project and run a diff between the apps to see what is different between my app and the new hotness in the latest Rails release. I noticed a difference in config/application.rb in the comments:

# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
In our app, for some reason, we had
config.action_view.javascript_expansions[:defaults] = %w()
There’s a lot of changes around Javascript in the Rails 3.0.4 release to handle some security vulnerabilities, so not surprised things changed here. We are telling are app the default expansion is an empty array — not so smart in any case. The fix was to add some elements to the default, in our case simply
config.action_view.javascript_expansions[:defaults] = %w(rails)
A server restart and everything is back to normal.

Tags:

6 Comments so far ↓

Leave a Comment