Reputation: 5619
I try to pass a param to a partial in view
controller
def addMovie
@movies = Movie.all
@vid = Movie.new
end
view
<%= render partial: "shared/videoList", videoList: :movies %>
partial stored in app/views/sharead
<% if @videoList.present? %>
<% @videoList.each do |movie| %>
videoList is empty ... why?
Upvotes: 0
Views: 94
Reputation: 17834
Access the variable using videoList
and not @videoList
,
<% if videoList.present? %>
<% videoList.each do |movie| %>
also, you need to pass the variable like this
<%= render 'shared/videoList', videoList: @movies %>
Hope that helps!
Upvotes: 4