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.
Hey thanks alot for posting this. It potentially saved me an hour of more of “WTF?”‘s
Kirk
Thanks!
You saved me.
Thanks, you definitely saved me some time fumbling around with this.
Another rails3 speedbump passed – thanks! I encountered this problem in a newly created rails3 app that i made with the -J option (don’t use prototype).