You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
now we have two controller actions for ajax calls which in successful cases don't serve a html page back, just a html snippet for inserting or a state indicating success.
now the problem is if something wrong happens, what we can do to inform the user something is wrong? redirect_to is not going to work. I haven't tried render and I doubt that would be any better.
one is Answers#update
defupdateauthorize@answerif@answer.make_judge_identified!ActionCable.server.broadcast"game-#{@answer.question.game_id}: info",{message: "Judge made his choice",message_type: "info"}head:okelse# send from a remote call, so no redirect_to actuallyflash[:alert]="Judge choice has not been updated."redirect_toroot_pathendend
note that if authorize @answer fails the error gets handled by a general purpose method, which uses redirect_to
the other is Games#judge
defjudgeauthorize@gamerenderlayout: falseend
The text was updated successfully, but these errors were encountered:
In the happy path, we did broadcast info to users and return a 200 ok to the browser. We can use a javascript callback to do something with the 200 ok (ajax:success)
In the sad path, we might be able to use the oppsite info.
now we have two controller actions for ajax calls which in successful cases don't serve a html page back, just a html snippet for inserting or a state indicating success.
now the problem is if something wrong happens, what we can do to inform the user something is wrong?
redirect_to
is not going to work. I haven't triedrender
and I doubt that would be any better.one is
Answers#update
note that if
authorize @answer
fails the error gets handled by a general purpose method, which usesredirect_to
the other is
Games#judge
The text was updated successfully, but these errors were encountered: