Ruby on Rails Friday, February 10, 2017

On 10 February 2017 at 09:16, 'krfg' via Ruby on Rails: Talk
<> wrote:
> Once I completed Michael Hartl's tutorial, I packed my homepage in a partial
> and called it _social_layer.html.erb
> Then I inserted this partial in my new homepage and proceeded to develop my
> application.
> Therefore, an extract of application's new homepage looks like as follows:
> <!-- Tab panes -->
> <div class="tab-content">
> <div role="tabpanel" class="tab-pane active" id="social-layer">
> <%= render 'static_pages/social_layer' %>
> </div>
> <div role="tabpanel" class="tab-pane" id="atp-team">
> <% if @atp_tournaments.any? %>
> <ul>
> <% @atp_tournaments.each do |tournament| %>
> <li> <%= %>: <%= tournament.category %>
> </li>
> <% end %>
> </ul>
> <% end %>
> </div>
> ...
> As you can see this page is divided in sections or tabs, each one containing
> the respective code.
> I inserted Michael Hartl's tutorial in the first tab.
> There are two versions for my homepage, one dedicated to freshly registered
> users and one for users who have completed a certain selection.
> I called these two pages _non_gamers_home.html.erb and _gamers_home.html.erb
> The code above belongs to the version of the homepage dedicated to gamers
> (_gamers_home.html.erb)
> So my home.html.erb file is made up of if/else statements and contains these
> two partials.
> The problem is that If I run the integration test dedicated to the
> microposts interface (the _social_layer.html.erb partial), the test fails
> because all instance variables in my homepage that do not belong to the
> social layer partial (the first one is @atp_tournaments as you can see in
> the above code) result nil.
> I do not understand why this test fails.
> All these instance variables belong to the controller that controls the home
> page (static_pages_controller.rb) and should be loaded by the test.
> If I change these variables with their explicit value in the above code the
> test passes.

Is it only the test that fails (as is suggested by your post) or does
it also fail when you run the app? If the latter is the case then the
problem is not to do with the test but is to do with the code itself.


You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment