mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 19:27:52 +01:00
Add gravatar picture to comments
This commit is contained in:
@@ -3,9 +3,16 @@ class CommentsController < ApplicationController
|
||||
|
||||
def index
|
||||
comments = Comment
|
||||
.select(
|
||||
:id,
|
||||
:body,
|
||||
:parent_id,
|
||||
:updated_at,
|
||||
'users.full_name as user_full_name',
|
||||
'users.email as user_email',
|
||||
)
|
||||
.where(post_id: params[:post_id])
|
||||
.left_outer_joins(:user)
|
||||
.select('comments.id, comments.body, comments.parent_id, comments.updated_at, users.full_name as user_full_name')
|
||||
.order(updated_at: :desc)
|
||||
|
||||
render json: comments
|
||||
@@ -15,8 +22,9 @@ class CommentsController < ApplicationController
|
||||
comment = Comment.new(comment_params)
|
||||
|
||||
if comment.save
|
||||
render json: comment.attributes.merge({ user_full_name: current_user.full_name}),
|
||||
status: :created
|
||||
render json: comment.attributes.merge(
|
||||
{ user_full_name: current_user.full_name, user_email: current_user.email}
|
||||
), status: :created
|
||||
else
|
||||
render json: {
|
||||
error: I18n.t('errors.comment.create', message: comment.errors.full_messages)
|
||||
|
||||
Reference in New Issue
Block a user