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:
ActionView::Template::Error (
(in /home/me/dev/ruby/demo1/app/assets/javascripts/say.js.coffee)):
3: <head>
4: <title>Demo1</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
app/views/layouts/application.html.erb:6:in
`_app_views_layouts_application_html_erb___558576499_89622220'
The problematic line of application.html.erb is:
<%= javascript_include_tag "application" %>
When I created the application using Rails 3.0 this particular line was:
<%= javascript_include_tag :defaults %>
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.0
Contents 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.
The problem was the app/assets/javascripts/application.js file contained commented out code. However, one of the commented out lines was as follows:
//= require_tree .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With