Ruby on Rails Friday, February 10, 2017

On Friday, February 10, 2017 at 2:32:49 PM UTC+1, Colin Law wrote:
On 10 February 2017 at 12:44, 'krfg' via Ruby on Rails: Talk
<> wrote:
> ...
> As you suggested I inserted immediately after the declaration of
> @atp_tournaments in static_pages_controller.rb:
>   def home
>       if logged_in? && !current_user.gamer?
>             ...
>       elsif logged_in? && current_user.gamer?
>             ...
>           @week_num ="%W").to_i
>           @atp_tournaments = AtpCalendar.where("week @> ?",
> "{#{@week_num}}")
> "atp tournaments count = #{@atp_tournaments.count}")
>           @wta_tournaments = WtaCalendar.where("week @> ?",
> "{#{@week_num}}")
>       end
>   end
> Using tail -n 100 log/test.log I got the following outut:
> atp tournaments count = 0

Good, so now we can be confident that it is getting to that line. One
thing that confuses me is that in an earlier post you showed the

ERROR["test_micropost_interface", MicropostsInterfaceTest, 6.374447322000378]
 test_micropost_interface#MicropostsInterfaceTest (6.37s)
ActionView::Template::Error:         ActionView::Template::Error:
undefined method `any?' for nil:NilClass
            app/controllers/microposts_controller.rb:12:in `create'
            test/integration/microposts_interface_test.rb:16:in `block
(2 levels) in <class:MicropostsInterfaceTest>'
            test/integration/microposts_interface_test.rb:15:in `block
in <class:MicropostsInterfaceTest>'

which suggests that you are in the create method of the microposts
controller.  What I don't understand is how it then getting to the
static pages controller. Can you post the start of
microposts_controller.rb (up to at least line 12) and also the start
of static_pages/home.html.erb.

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 %>

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