设计重定向到登录并在表单发布上注销用户

| 设计1.2 栏杆3.0.5 我的控制器中有这个:
before_filter :authenticate_user!
提交表单后,我将重定向到“登录”页面,并且用户将自动注销。即使他们已经登录,这似乎也在表单发布中发生。这是存在问题的操作:
def next
  myObject = theObject.first
  myObject.current_number = params[:next_number]
  myObject.save!
  redirect_to :action => \'index\'
end
在我看来:
%form{:method => \"post\"}
%input#nextNumber{:name => \"next_number\", :type => \"hidden\", :value => \"7\"}/
在js中触发如下:
$(\"form\").submit();
任何想法为什么会这样?找不到任何有用的信息...     
已邀请:
看来您可能已经用另一种方式解决了您的问题,但是我遇到了一个类似的问题,该问题最终与表单上缺少真实性令牌有关。该视图未使用Rails form_for帮助器,因此,表单提交中没有包含authenticity_token。 即。
<form action=\"...\" method=\"POST\">...</form>
变成
<%= form_for :form, :url => \"...\" do |f| %> ... <% end %>
结果是
<form action=\"...\" method=\"POST\">
  <input name=\"authenticity_token\" type=\"hidden\" value=\"...\">
  ...
</form>
有关authenticity_token的更多详细信息:了解Rails的真实性令牌     

要回复问题请先登录注册