Question

only on tutorial 5 and I am stumped.

This is similar to a previous post by user1420228, but the answer given didn't really resolve the problem.

In Michael Hartl's application_helper.rb file:

<!DOCTYPE html>
<html>
    <head>
  <title> <%=full_title(yield(:title)) %> </title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
<body>
    <%= yield %>
</body>
</html>

However, he suggests changing the :media hash to the newer media:. He makes the change and demonstrates the sample app working. I made the same change and the sample app failed with the following error:

 SyntaxError in Static_pages#home

Showing /Users/osmanahmed/Rails_Projects/sample_app/app/views/layouts/application.html.erb where line #5 raised:

/Users/osmanahmed/Rails_Projects/sample_app/app/views/layouts/application.html.erb:5: syntax error, unexpected tASSOC
...tag    "application", media: => "all" );@output_buffer.safe_...
...                               ^

Extracted source (around line #5):

2: <html>
3:  <head>
4:    <title> <%=full_title(yield(:title)) %> </title>
5:    <%= stylesheet_link_tag    "application", media: => "all" %>
6:    <%= javascript_include_tag "application" %>
7:    <%= csrf_meta_tags %>
8:  </head>

Trace of template inclusion: app/views/layouts/application.html.erb

Rails.root: /Users/osmanahmed/Rails_Projects/sample_app

ruby -v gives me: ruby 1.9.3p392

rvm -v gives me 1.20.13

rails - v is 3.2.13

As a side issue, if I ignore the change to the new hash everything works fine, but if I progress further in the tutorial I find that my static home page contents load twice. So I suspect I should try and fix this issue before I try and debug the new "page loading twice error"

I am guessing this is a configuration issue, either I have loaded the incorrect gemfile or something.

Can anyone point me in the right direction please?

Oz

Was it helpful?

Solution

Looks like you're doing media: => "all". It should be media: "all". No hash-rocket.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top