mercredi 6 mai 2015

Ruby ternary operator and method call

I am using ruby 2.1.5, facing some problem with ternary operator

Syntax error

request.xhr?  ? render :json => "success"  : redirect_to index_url

working

request.xhr?  ? render(:json => "success") : redirect_to(index_url)

Can some please explain How its works and why above one not working? Thanks in advance

Aucun commentaire:

Enregistrer un commentaire