0

I'm following Michael Hartl Ruby on Rails tutorial. At the end of paragraph 5.3.1 I'm running the tests that we've programmed as part of the tutorial. For all 4 tests/views it generates the following error:

ERROR["test_should_get_about", StaticPagesControllerTest, 0.207317345] test_should_get_about#StaticPagesControllerTest (0.21s) ActionView::Template::Error:         ActionView::Template::Error: Missing partial layouts/_shim with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
          * "/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates"
          * "/home/ubuntu/workspace/sample_app/app/views"
          * "/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/web-console-2.0.0.beta3/app/views"

            app/views/layouts/application.html.erb:9:in `_app_views_layouts_application_html_erb___3690625791535586393_66697380'
            test/controllers/static_pages_controller_test.rb:17:in `block in <class:StaticPagesControllerTest>'
        app/views/layouts/application.html.erb:9:in `_app_views_layouts_application_html_erb___3690625791535586393_66697380'
        test/controllers/static_pages_controller_test.rb:17:in `block in <class:StaticPagesControllerTest>'

I have a file app/views/layouts/_shim.html.erb, so that seems okay, and application.html.erb is:

<!DOCTYPE html>
<html>
  <head>
    <title><%= full_title(yield(:title)) %></title>
    <%= stylesheet_link_tag "application", media: "all",
                                           "data-turbolinks-track" => true %>
    <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
    <%= csrf_meta_tags %>
    <%= render 'layouts/shim' %>
  </head>
  <body>
    <%= render 'layouts/header' %>
    <div class="container">
      <%= yield %>
      <%= render 'layouts/footer' %>
    </div>
  </body>
</html>

The test is:

  test "should get about" do
    get :about
    assert_response :success
    assert_select "title", "About | Ruby on Rails Tutorial Sample App"
  end

I don't understand what what causes the error. In the controller it just read def about; end and the routes get 'static_pages/about'

The project structure is:

  • Sample_app
    • .bundle
    • .git
    • App
      • Assets
        • Images
        • Javascripts
        • Stylesheets
      • Controllers
      • Helpers
      • Mailers
      • Models
      • Views
        • layouts
          • _footer.html.erb
          • _header.html.erb
          • _shim.html.erb
          • application.html.erb
        • static_pages
          • about.html.erb
          • contact.html.erb
          • help.html.erb
          • home.html.erb
    • Bin
    • Config
    • Db
    • Lib
    • Log
    • Public
    • Spring
21
  • Missing partial layouts/_shim u have that trouble, can u show ur project structure? Commented Mar 18, 2015 at 11:33
  • Thanks, I've added the project structure. Hope that helps. Rendering the header and footer doesn't seem to generate a problem and I don't see a difference with shim... Commented Mar 18, 2015 at 11:46
  • show me views/layouts ls -la Commented Mar 18, 2015 at 11:47
  • Does the shim show up when you view the page? Commented Mar 18, 2015 at 11:48
  • I’ve added the structure for the views directory. I’m not sure what you meant with ls la (sorry, really new to this and only familiar with Windows). When I enter app/views/layouts ls -la in the terminal it just sais “bash: app/views/layouts: Is a directory”. Commented Mar 18, 2015 at 11:54

1 Answer 1

1

You have spaces in your file names, just rename them to:

_header.html.erb
_shim.html.erb
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.