Simplify user action make it more idiomatic

This commit is contained in:
Sam
2013-05-27 10:22:37 +10:00
parent 6046d33645
commit d84ae80074
4 changed files with 70 additions and 36 deletions

View File

@@ -14,12 +14,15 @@ class UserActionsController < ApplicationController
ignore_private_messages: params[:filter] ? false : true
}
if opts[:action_types] == [UserAction::GOT_PRIVATE_MESSAGE] ||
opts[:action_types] == [UserAction::NEW_PRIVATE_MESSAGE]
render json: UserAction.private_message_stream(opts[:action_types][0], opts)
else
render json: UserAction.stream(opts)
end
stream =
if opts[:action_types] == [UserAction::GOT_PRIVATE_MESSAGE] ||
opts[:action_types] == [UserAction::NEW_PRIVATE_MESSAGE]
UserAction.private_message_stream(opts[:action_types][0], opts)
else
UserAction.stream(opts)
end
render_serialized(stream, UserActionSerializer, root: "user_actions")
end
def show