1
我需要一個表單頁面,每個表單提交到同一個索引頁面。在每次提交時,根據輸入字段的驗證方式顯示不同的視圖。如何在提交到相同頁面時添加到導軌會話?
控制器:
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
有人能告訴我如何從每個視圖到會話中添加表單數據[:報價]不會覆蓋時間整個塊?