I’ve created a clean and simple Rails 3.1 application called demo1. It contains two controllers – hello and goodbye. I get the following error when I try to load http://localhost:3000/say/hello:
The problematic line of application.html.erb is:
When I created the application using Rails 3.0 this particular line was:
And this worked fine. In fact, when I change the application.html.erb to use :defaults everything works, but I want to use the new features of Rails 3.1.
I can’t seem to turn up anything on Google around this, I guess because Rails 3.1 has just been released.
By the way, I’m following the first chapter in the Agile Web Development with Rails (4th edition) Updated for Rails 3.1 book.
Some environmental info that may help in answering this question:
$ cat /etc/issue Ubuntu 10.04.2 LTS \n \l $ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] $ rails -v Rails 3.1.0Contents of the say.js.coffee file:
# Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
Ok, I’ve figured out what the issue was, and so I’ll answer my own question.
When I delete this line everything works fine.
Hope this helps. If someone can provide some insight as to why the underscore was causing the issue that would be great.
In Rails 3.1 there is no longer a “defaults” as such, but rather what is specified in your
application.js file are the “defaults”. You would include this file using this line:
jquery_ujs files come with the
jquery-rails gem which is in the default Rails 3.1
//= require line in that file tells Sprockets that you want to require a file which in this case would be
jquery.js from within
jquery-rails, where the
application.js and concatenate them all into one file.
You can read more about the asset pipeline here.