我刚刚观看了多步表单的 railscasts ,现在我有一个多步表单,在创建新实例时效果很好,但是更新和编辑不起作用,它执行多步,但是当我单击最后一步的继续时,它只是没有更新,似乎会话丢失了...
这是控制器...如果我使用
session[:location_params].deep_merge!(params[:location]) if params[:location]
发生一个错误,指出无法完成 deep_merge...
def edit
@location = Location.find(params[:id])
session[:location_params] = @location
@location.current_step = session[:location_step] = @location.steps.first
end
def update
@location = Location.find(params[:id])
@location.current_step = session[:location_step]
if params[:back_button]
@location.previous_step
elsif @location.last_step?
@location.save if @location.all_valid? and @location.changed?
else
@location.next_step
end
session[:location_step] = @location.current_step
if @location.created_at_changed?
flash[:success] = "Location updated!"
session[:location_step] = session[:location_params] = nil
redirect_to @location
else
render 'edit'
end
end
感谢您的帮助和指导。