Get more comment information from the server
This commit is contained in:
@ -19,6 +19,8 @@ class CommentsController < ApplicationController
|
||||
@comments = Comment.where(file_id: params[:file_id])
|
||||
@comments.map{|comment|
|
||||
comment.username = comment.user.displayname
|
||||
comment.date = comment.created_at.strftime('%d.%m.%Y %k:%M')
|
||||
comment.updated = (comment.created_at != comment.updated_at)
|
||||
}
|
||||
else
|
||||
@comments = []
|
||||
|
@ -1,7 +1,7 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
# inherit the creation module: encapsulates that this is a polymorphic user, offers some aliases and makes sure that all necessary attributes are set.
|
||||
include Creation
|
||||
attr_accessor :username
|
||||
attr_accessor :username, :date, :updated
|
||||
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
belongs_to :user, polymorphic: true
|
||||
|
@ -1,4 +1,4 @@
|
||||
json.array!(@comments) do |comment|
|
||||
json.extract! comment, :id, :user_id, :file_id, :row, :column, :text, :username
|
||||
json.extract! comment, :id, :user_id, :file_id, :row, :column, :text, :username, :date, :updated
|
||||
json.url comment_url(comment, format: :json)
|
||||
end
|
||||
|
Reference in New Issue
Block a user