Question

I am new to Ruby on Rails and am following the Rails Tutorials by Michael Hartl.

According to the book, I had downloaded a set of CSS and placed it in /public/stylesheets/ folder. Also, I had placed a logo.png file in public/images folder. When I request a page from the browser, the logo is not displayed and instead, the Alt text is displayed. Also, I think the CSS is not linked too.

I seemed to have done exactly what the book said. Not sure what the problem is.

Rails 3.2.8, ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Here is the layout application.html.erb page:

<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>

<!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->

<%= stylesheet_link_tag 'custom', :media => 'screen' %>

</head>
<body>


<div class="container">
    <header>
        <%= image_tag("logo.png", :alt=>"Sample App", :class => "round") %>
        <nav class="round">
            <ul>
                <li><%= link_to "Home", '#' %></li>
                <li><%= link_to "Help", '#' %></li>
                <li><%= link_to "Sign in", '#' %></li>
            </ul>

        </nav>
    </header>

    <section class="round">
        <%= yield %>
    </section>


</body>
</html>
Was it helpful?

Solution

Rails 3.X has stylesheets in app/assets/stylesheets, and images in app/assets/images.

The other advice is good too... use the latest version of the tutorial and check out rvm.

OTHER TIPS

Why are you following older edition of the tutorial? There is slightly newer version on his site. You should definitely check it out.

Are you using Rails 3? If you are, the proper place to put your stylesheets is now in assets. You can find them in app/assets/ stylesheets.

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