Ruby on rails 3 设计重定向到表单post上的登录和注销用户

Ruby on rails 3 设计重定向到表单post上的登录和注销用户,ruby-on-rails-3,authentication,devise,Ruby On Rails 3,Authentication,Devise,设计1.2 rails 3.0.5 我在我的控制器中有这个:before\u filter:authenticate\u user 提交表单时,我将重定向到登录页面,用户将自动注销。即使他们已经登录,这似乎是发生在表单张贴。这是有问题的行动: def next myObject = theObject.first myObject.current_number = params[:next_number] myObject.save! redirect_to :action =&

设计1.2 rails 3.0.5

我在我的控制器中有这个:
before\u filter:authenticate\u 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表单\u作为帮助程序,因此表单提交中没有包含真实性\u标记

。。。
改为

<%= form_for :form, :url => "..." do |f| %> ... <% end %>
“…”do | f |%>。。。
导致

<form action="..." method="POST">
  <input name="authenticity_token" type="hidden" value="...">
  ...
</form>

...

有关真实性的更多详细信息\u令牌:

升级到最新的rails似乎可以做到这一点。似乎是一个rails错误,但如何使用Curl注销?它只是将我重定向到登录,而不会将json发送回:
<form action="..." method="POST">
  <input name="authenticity_token" type="hidden" value="...">
  ...
</form>