Can refresh queued posts via button

This commit is contained in:
Robin Ward
2015-04-27 13:52:37 -04:00
parent cce8693354
commit 3cb4554bbb
8 changed files with 74 additions and 7 deletions

View File

@ -224,7 +224,14 @@ class ApplicationController < ActionController::Base
def render_json_dump(obj, opts=nil)
opts ||= {}
obj['__rest_serializer'] = "1" if opts[:rest_serializer]
if opts[:rest_serializer]
obj['__rest_serializer'] = "1"
opts.each do |k, v|
obj[k] = v if k.to_s.start_with?("refresh_")
end
end
render json: MultiJson.dump(obj), status: opts[:status] || 200
end

View File

@ -9,7 +9,12 @@ class QueuedPostsController < ApplicationController
state ||= QueuedPost.states[:new]
@queued_posts = QueuedPost.visible.where(state: state).includes(:topic, :user)
render_serialized(@queued_posts, QueuedPostSerializer, root: :queued_posts, rest_serializer: true)
render_serialized(@queued_posts,
QueuedPostSerializer,
root: :queued_posts,
rest_serializer: true,
refresh_queued_posts: "/queued_posts?status=new")
end
def update