javascript_include_tag error

<!DOCTYPE html>
<html>
<head>
  <title><%= @title %></title>
  <%= csrf_meta_tag %>
  <%= javascript_include_tag
"http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js",
"jquery.rails.js"
  %>

<script type="text/javascript">

...app/views/layouts/application.html.erb:7: syntax error, unexpected
',', expecting ')'
...bs/jquery/1.6.2/jquery.min.js", "jquery.rails.js"
... ^
Extracted source (around line #7):

4: <title><%= @title %></title>
5: <%= csrf_meta_tag %>
6: <%= javascript_include_tag
7: "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js",
"jquery.rails.js"
8: %>
9:
10: <script type="text/javascript">

As far as I can tell, that is the same syntax used at the end of this
railscast:

http://railscasts.com/episodes/205-unobtrusive-javascript

I guess I can always just do this:

  <script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"

</script>

  <script type="text/javascript", src="jquery.rails.js" ></script>

but I'm still wondering why I got the error.

Ruby looks at the code in line 6, and thinks you're just calling javascript_include_tag without any arguments. It then tries to parse line 7 as a new statement, but doesn't know what to do with a string followed by a comma.

If you put the first argument to javascript_include_tag on the same line (i.e. combine lines 6 and 7), then Ruby will know you're listing arguments to javascrip_include_tag, and it'll work.

Chris

Chris M. wrote in post #1016050:

If you put the first argument to javascript_include_tag on the same line
(i.e. combine lines 6 and 7), then Ruby will know you're listing
arguments to javascrip_include_tag, and it'll work.

Thanks. That means I can do this:

  <%=
    javascript_include_tag(
      "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js",
      "jquery.rails.js")
  %>