undefined method `any?' for nil:NilClass 2
<p>i'm trying to show all the videos in my app so when i'm adding a new video and want to redirect to movie_path so i did this in my video controller:</p>

<pre><code>def create
  @video = Video.new(video_params)
  if @video.save
    flash[:success] = 'Video added!'
    redirect_to movie_path(@movies)
  else
    render :new
  end
end
</code></pre>

<p>it gives me an error:
undefined method `any?' for nil:NilClass
this is my show page that want to show the video:</p>

<pre><code>&lt;% if @videos.any? %&gt;
 &lt;div class="container"&gt;
  &lt;div id="player-wrapper"&gt;&lt;/div&gt;
   &lt;% @videos.in_groups_of(3) do |group| %&gt;
    &lt;div class="row"&gt;
     &lt;% group.each do |video| %&gt;
      &lt;% if video %&gt;
        &lt;div class="col-md-4"&gt;
          &lt;div class="yt_video thumbnail"&gt;
            &lt;%= link_to image_tag("https://img.youtube.com/vi/#{video.uid}/mqdefault.jpg", alt: video.title,
                                  class: 'img-rounded'),
                        "https://www.youtube.com/watch?v=#{video.uid}", target: '_blank' %&gt;
            &lt;div class="caption"&gt;
              &lt;h5&gt;&lt;%= video.title %&gt;&lt;/h5&gt;
              &lt;p&gt;Published at &lt;%= video.published_at.strftime('%-d %B %Y %H:%M:%S') %&gt;&lt;/p&gt;
              &lt;p&gt;
                &lt;span class="glyphicon glyphicon glyphicon-thumbs-up"&gt;&lt;/span&gt; &lt;%= video.likes %&gt;
                &lt;span class="glyphicon glyphicon glyphicon-thumbs-down"&gt;&lt;/span&gt; &lt;%= video.dislikes %&gt;
              &lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;% end %&gt;
    &lt;% end %&gt;
  &lt;/div&gt;
&lt;% end %&gt;
</code></pre>

<p></p>

<p>this is movie controller:</p>

<pre><code>def index
  @movies = Movie.all.order(:cached_votes_score =&gt; :desc)
  @movies = @movies.paginate(:page =&gt; 1, :per_page =&gt; 8)

end

def show
  @reviews = Review.where(movie_id: @movie.id).order("created_at DESC")
end

def new
  @movie = current_user.movies.build
  @movie = Movie.new 
  @categories = Category.all.map{|c| [ c.name, c.id ] }
end
</code></pre>

<p>and this is the routes i have:</p>

<p><a href="https://i.stack.imgur.com/1g9bh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1g9bh.png" alt="enter image description here"></a></p>