Jquery 设计在.js调用[AJAX]时立即过期的会话

Jquery 设计在.js调用[AJAX]时立即过期的会话,jquery,ajax,ruby-on-rails-3,devise,Jquery,Ajax,Ruby On Rails 3,Devise,通过多次尝试和错误,我已将问题缩小到下面的第5行。出于某种原因,.js响应正在结束用户会话。使用3.0.4并设计1.1.7(和jQuery 1.5) 此外,@organization正在更新并完成日志中显示的200 OK,因此在尝试下一个操作之前,用户不知道自己已注销 非常感谢您的帮助和指导 *Controller* 1 def make_featured 2 @organization = Organization.find(params[:id]) 3 @organiza

通过多次尝试和错误,我已将问题缩小到下面的第5行。出于某种原因,.js响应正在结束用户会话。使用3.0.4并设计1.1.7(和jQuery 1.5)

此外,@organization正在更新并完成日志中显示的200 OK,因此在尝试下一个操作之前,用户不知道自己已注销

非常感谢您的帮助和指导

*Controller*
1   def make_featured
2     @organization = Organization.find(params[:id])
3     @organization.is_featured ? @organization.update_attribute(:is_featured,"false") :   @organization.update_attribute(:is_featured,"true")
4       respond_to do |format|
5         format.js {render :action => "update", :layout => false}
6       end
7   end


非常感谢Desive Google Group的Brandon Martin为我指明了正确的方向

这是Rails 3.0.4安全修复的结果

经过一个小时左右的努力,从这个博客文章,这里有一些提示给其他人

  • 这已经在rails.js中得到了修复-因此您不必破解、修补或重新发明轮子
  • 如果您使用的是现成的rails.js,请更新它-
    rake rails:update
    (我想,但我使用的是定制的rails.js文件)
  • 如果您使用的是自定义rails.js文件,请在此处获取最新版本的源代码:
  • 将您的
    csrf\u meta\u标记
    helper放在您的
    javascript\u include\u标记
    s上方

希望有帮助

http://codeglot.com/posts/48-ajax_posting_to_rails_with_crsf_meta_tag
为我工作。基本上,它包括向AJAX头添加
X-CSRF-Token
*update.js.haml*
$("#organization_" + "#{@organization.id}" ).replaceWith("#{ escape_javascript(render :partial => 'users/supplier_view', :locals => {:organization => @organization}) }");