Ruby on Rails Friday, February 10, 2017

The home page is controlled by static_pages_controller.rb
However the part of the home page concerning microposts creation and deletion is controlled by the microposts controller.
Below is an extract of microposts_controller.rb

class MicropostsController < ApplicationController
  before_action :logged_in_user, only: [:create, :destroy]
  before_action :correct_user,   only: :destroy

  def create
    @micropost =
      flash[:success] = "Micropost created!"
      redirect_to root_url
      @feed_items = []
      render 'static_pages/home'

Line 12 is exactly render 'static_pages/home'
app/view/static_pages/home.html.erb is all below:

<% if logged_in? %>
  <% if current_user.gamer? %>
    <%= render 'static_pages/gamers_home' %>
  <% else %>
    <%= render 'static_pages/non_gamers_home' %>
  <% end %>
<% else %>
  <%= render 'static_pages/non_logged_in_home' %>
<% end %>

The lines of the test that are mentioned by the test itself (lines 15 and 16) are:

    assert_no_difference 'Micropost.count' do
      post microposts_path, params: { micropost: { content: "" } }

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