How to redirect from within a .js script

I need to redirect from within an action called by an Ajax request

  def create .. respond_with resource do |format| format.js { .. # test on user locale and changed         I18n.default_locale = resource.current_membership.account_type.locale.code.to_sym          I18n.locale = I18n.default_locale         session[:return_to]["locale"] = I18n.locale.to_s @url = session[:return_to] || root_path         session[:return_to] = nil render :action => "signed_in.js" }

I think you’d need to generate the root_path for the specific locale…

root_path(:locale => I18n.locale)