From 938111ee4b19fe2ad96a4b0629cc2ad840cdbabe Mon Sep 17 00:00:00 2001 From: Mateus Rambo Strey <mars11@inf.ufpr.br> Date: Wed, 17 Feb 2016 11:56:14 -0200 Subject: [PATCH] add button for new review and small fix --- app/controllers/collections_controller.rb | 2 +- app/controllers/learning_objects_controller.rb | 2 +- app/views/collections/show.html.erb | 2 ++ app/views/learning_objects/show.html.erb | 10 +++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 2e51f4f9..25859ba9 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -36,7 +36,7 @@ class CollectionsController < ApplicationController @own = user_signed_in? ? @collection.owner?(current_user) : false end - @reviews = Review.where(reviewable: @collection) + @reviews = Review.includes(:user).where(reviewable: @collection) render partial: 'list' if params[:list] == 'true' end diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index ebb26778..e92f8208 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -15,7 +15,7 @@ class LearningObjectsController < ApplicationController # GET /learning_objects/1.json def show @liked = !@learning_object.likes.where(user: current_user).blank? if user_signed_in? - @reviews = Review.where(reviewable: @learning_object) + @reviews = Review.includes(:user).where(reviewable: @learning_object) end # GET /learning_objects/new diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index 8b1d8f2d..dbcbb382 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -64,6 +64,8 @@ </div> </nav> +<%= link_to 'Avalie esta coleção!', new_review_path(reviewable_id: @collection.id, reviewable_type: @collection.class.name), class: 'btn btn-success' %> + <div class="row"> <div class="learning-object-columns"> <br/> diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb index bb86cd80..6e5105d0 100644 --- a/app/views/learning_objects/show.html.erb +++ b/app/views/learning_objects/show.html.erb @@ -85,9 +85,6 @@ </div> </div> </div> - <div class="col-md-12"> - <%= render 'reviews/list' %> - </div> </div> <br/> @@ -129,7 +126,14 @@ </div> </div> </div> +<%= link_to 'Avalie este objeto!', new_review_path(reviewable_id: @learning_object.id, reviewable_type: @learning_object.class.name), class: 'btn btn-success' %> +<br/><br/> +<div class="row"> + <div class="col-md-12"> + <%= render 'reviews/list' %> + </div> +</div> <script type="text/javascript"> $(".view video").hover(function(event) { -- GitLab