Ruby on Rails Friday, February 10, 2017

On 10 February 2017 at 13:46, 'krfg' via Ruby on Rails: Talk
<> wrote:
> ...
> 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 =
> if
> flash[:success] = "Micropost created!"
> redirect_to root_url
> else
> @feed_items = []
> render 'static_pages/home'

The render line does not invoke the static_pages controller, it just
invokes the view files for static_pages/home, so it will not call the
static_pages controller to setup your variables. I don't know how your
debug got to that code, I suspect it was from a different part of the
test. Perhaps you meant redirect_to which will invoke the controller
to perform the action. You may find this useful -


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