我需要一行中的多个表单页面,每个表单都提交到同一个索引页面。根据输入字段的验证方式,每次提交都会显示不同的视图。
控制器:
class FormsController < ApplicationController
include FormsHelper
def index
#if we know what view to show, show it, else show first view in the flow
if(!session.has_key?(:flow_page))
set_flow_page
end
# if form was submitted, I want to add this pages submit data to what I already have in session[:quote]
if(params.has_key?(:form))
temp = params[:form]
form = session[:quote]
form.merge(temp)
#session[:quote].deep_merge!(session[:temp])
end
# other stuff
if params[:back] == "Back" && params[:flow][:previous_page] != "refused"
session[:flow_page] = params[:flow][:previous_page]
end
if params[:next] == "Next"
session[:flow_page] = params[:flow][:next_page]
end
end
end
有人能告诉我如何将每个视图中的表单数据添加到 session[:quote] 中,而不会每次都覆盖整个块吗?