diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 98357e96e..0f5cb680b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -45,12 +45,13 @@ class CommentsController < ApplicationController def comment_params params.require(:comment).permit(:commentable_type, :commentable_id, :parent_id, - :body, :as_moderator, :as_administrator) + :body, :as_moderator, :as_administrator, :valuation) end def build_comment @comment = Comment.build(@commentable, current_user, comment_params[:body], - comment_params[:parent_id].presence) + comment_params[:parent_id].presence, + comment_params[:valuation]) check_for_special_comments end diff --git a/app/models/comment.rb b/app/models/comment.rb index 0651b3442..3c58f966b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -55,11 +55,12 @@ class Comment < ActiveRecord::Base after_create :call_after_commented - def self.build(commentable, user, body, p_id = nil) - new commentable: commentable, + def self.build(commentable, user, body, p_id = nil, valuation = false) + new(commentable: commentable, user_id: user.id, body: body, - parent_id: p_id + parent_id: p_id, + valuation: valuation) end def self.find_commentable(c_type, c_id) diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 8d45b5469..a5d84166e 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,4 +1,5 @@ <% comment_flags ||= @comment_flags %> +<% valuation = local_assigns.fetch(:valuation, false) %> <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>