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 = current_user.microposts.build(micropost_params)
if @micropost.save
flash[:success] = "Micropost created!"
redirect_to root_url
else
@feed_items = []
render 'static_pages/home'
end
end
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: "" } }
end
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c11797fc-3dcc-4325-8b65-050655d50eb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment