First things first. Views refer to actions in controllers. So there can be several views for each controller or even none.
So, if you want to render @reviews
and @logs
on the same page you should first instantiate both instance variables in the same action and then render both partials in the same action.
How do you do that? Easy.
First you got to the controller you just showed and edit that show
action.
def show
# You can set the variable in the if-clause
# And you also need to use static finders with a hash as an argument in Rails4
if (@user = User.find_by(name: params[:id]))
@reviews = @user.reviews.all
@logs = @user.logs.all
# You don't need to call render explicitly
# if you render the view with the same name as the action
else
render file: 'public/404', status: 404, formats: [html]
end
end
Second: you go to your /app/views/reviews/show.html.erb
template and put both partials there like this (this is just an example, adjust your markup to fit your needs).
<h1> Reviews and Logs</h1>
<div id="reviews_part">
<%= render @reviews %>
</div>
<div id="logs_part">
<%= render @logs %>
</div>
Now create 2 new partials /app/views/reviews/_review.html.erb
and /app/views/logs/_log.html.erb
and put all the needed markup there (use regular variables review
and log
to adress the repeating objects). Rails will automaticaly repeat those partials as many times as needed.
Or you can explicitely call the partial render
<div id="reviews_part">
<% @reviews.each do |review| %>
<%= render review %>
which is the same as
<%= render partial:"reviews/review", locals:{review:review} %>
<% end %>
</div>