I'm not sure if this behavior is normal or not, but when I do:
render js: "window.location.pathname = '#{new_user_session_path}';"
in my controller, it briefly displays the text window.location.pathname = '/user/sign_in';
before executing the line and redirecting successfully.
Here's the full controller action:
def vote_down if user_signed_in? current_user.vote_exclusively_against(@deal = Deal.find(params[:id])) render :partial => 'deals/partials/interaction', :locals => {:deal => @deal, :votes_for => @deal.votes_for, :votes_against => @deal.votes_against} else render js: "window.location.pathname = '#{new_user_session_path}';" flash[:error] = 'Please sign in to vote.' end end
How do I prevent this from happening and directly render that template?