表单提交后会话变量从会话中删除

时间:2012-07-26 16:49:53

标签: ruby-on-rails ruby-on-rails-3 session cookies

我在show中设置了会话var:time_block_id。 提交表单时,您会看到相同的session_id和_csrf_token,但是:time_block_id已消失。有任何想法吗? Rails 3.2.6

controller.rb

def show
  session[:time_block_id] = "test"
  debugger
  (rdb:663) p session 
  # outputs ...
  {"session_id"=>"1232115b1ffe78b7e71163e4bd48974a", "user_return_to"=>"/app/admin/clients", "_csrf_token"=>"/aFAp07yrpQtjgXDS2HQk+uNZLD3QuGRzSGX4Mszyug=", "warden.user.user.key"=>["User", [2], "$2a$10$1Mn/Riq9WdmnUUUiVhXbsO"], "time_block_id"=>"test"}

  render_wizard
end

def update
  debugger
  (rdb:663) p session
{"session_id"=>"1232115b1ffe78b7e71163e4bd48974a", "user_return_to"=>"/app/admin/clients", "_csrf_token"=>"/aFAp07yrpQtjgXDS2HQk+uNZLD3QuGRzSGX4Mszyug=", "warden.user.user.key"=>["User", [2], "$2a$10$1Mn/Riq9WdmnUUUiVhXbsO"]}

  a = ""
end

_form.html.haml

=simple_form_for @time_block, url: wizard_path, :method => :put do |f|
    =f.submit "go" 

1 个答案:

答案 0 :(得分:0)

我建议你在“warden.user.user.key”之前移动“time_block_id”变量,并检查游览模型。 如果没有错误消息,上一个参数的错误很可能会阻止其余的进程。