Ich versuche, die Videos alle in meiner app zu zeigen, so dass, wenn ich ein neues Video bin das Hinzufügen und wollen umleiten, so tat ich dies in meinem Video-Controller movie_path:undefinierte Methode `any? ' für nil: NilClass 2
def create
@video = Video.new(video_params)
if @video.save
flash[:success] = 'Video added!'
redirect_to movie_path(@movies)
else
render :new
end
end
es gibt mir einen Fehler: undefined Methode `any? ' für nil: NilClass das ist meine Show-Seite, die das Video angezeigt werden soll:
<% if @videos.any? %>
<div class="container">
<div id="player-wrapper"></div>
<% @videos.in_groups_of(3) do |group| %>
<div class="row">
<% group.each do |video| %>
<% if video %>
<div class="col-md-4">
<div class="yt_video thumbnail">
<%= 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' %>
<div class="caption">
<h5><%= video.title %></h5>
<p>Published at <%= video.published_at.strftime('%-d %B %Y %H:%M:%S') %></p>
<p>
<span class="glyphicon glyphicon glyphicon-thumbs-up"></span> <%= video.likes %>
<span class="glyphicon glyphicon glyphicon-thumbs-down"></span> <%= video.dislikes %>
</p>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
<% end %>
dies Film-Controller:
def index
@movies = Movie.all.order(:cached_votes_score => :desc)
@movies = @movies.paginate(:page => 1, :per_page => 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
und dies ist die Routen ich habe:
Nun, das funktioniert gut, aber ich habe einen anderen Fehler fehlende erforderliche Schlüssel: [: id] ... redirect_to movie_path (@movies) –