diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index bf154d85f..cc601e87f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -65,11 +65,11 @@ class CommentsController < ApplicationController if user_signed_in? @post = current_user.find_visible_shareable_by_id(Post, params[:post_id]) else - @post = Post.where(:id => params[:post_id], :public => true).includes(:author, :comments => :author).first + @post = Post.find_by_id_and_public(params[:post_id], true) end if @post - @comments = @post.comments.includes(:author => :profile).order('created_at ASC') + @comments = @post.comments.for_a_stream respond_with do |format| format.json { render :json => @comments.as_api_response(:backbone), :status => 200 } format.mobile{render :layout => false} diff --git a/app/models/comment.rb b/app/models/comment.rb index ef1e7c3eb..33446df3f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -38,6 +38,7 @@ class Comment < ActiveRecord::Base scope :including_author, includes(:author => :profile) + scope :for_a_stream, including_author.merge(order('created_at ASC')) before_save do self.text.strip! unless self.text.nil? diff --git a/app/models/person.rb b/app/models/person.rb index fbdd0c4ca..5509b6554 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -212,7 +212,7 @@ class Person < ActiveRecord::Base end def public_key_hash - Base64.encode64 OpenSSL::Digest::SHA256.new(self.exported_key).to_s + Base64.encode64(OpenSSL::Digest::SHA256.new(self.exported_key).to_s) end def public_key