foodsoft/plugins/messages/app/controllers/message_threads_controller.rb
Patrick Gansterer 8ac1471a89 Add message threads #394
This new view sorts the messages by threads based on the reply_to.
Now we store only the message which started a new thread in the reply_to
field to avoid recursive queries.
2016-03-04 16:52:34 +01:00

12 lines
344 B
Ruby

class MessageThreadsController < ApplicationController
before_filter -> { require_plugin_enabled FoodsoftMessages }
def index
@message_threads = Message.pub.threads.page(params[:page]).per(@per_page).order(created_at: :desc).includes(:sender)
end
def show
@messages = Message.thread(params[:id]).order(:created_at)
end
end