I have a form with :remote => true which means it will be submitted through ajax.
In the controller, I have such code:
before_filter: authenticate_us
You need do your own authenticate_user! action and in this action you can have the behaviour your want.
def authenticate_user! unless current_user render 'my_js' end end