I’m a rails beginner and I’m trying to render on my show (as in tv show) page
“@reviews by @sources”
and I’m not sure how to add a second method inside my render in my views
shows
controller:
def show
@show = Show.find(params[:id])
@reviews = @show.reviews.paginate(page: params[:page])
@sources = @show.reviews.source
respond_to do |format|
format.html # show.html.erb
format.json { render json: @show }
end
end
show view show.html.erb
<div class="span8">
<% if @show.reviews.any? %>
<h3>Reviews (<%= @show.reviews.count %>)</h3>
<ol class="reviews">
<%= render @reviews %>
</ol>
<%= will_paginate @reviews %>
<% end %>
</div>
</div>
any help ?!
You have a will paginate array called @reviews. this array has review objects. Now to display the contents of this array, what you need to do is, in the show.htm.erb.
The render method, which you have used is a method from ActionController, you can’t use that in the views.