私はRails 4 Appオーダーモデルを使用しています。価格計算などに必要なデータをユーザーがフォームに記入します。 step_3の最後にサインインするように促され、支払いセクションにルーティングされますが、ユーザーが以前に記入した注文モデルからフォームデータを保存できます。このデータは注文フォームデータです。サインフォームデータをレールで保持したままフォームに記入してサインインする方法
主な問題点:を考案使ってプロセスを通じて半ば方法で記号の後にそれらをリダイレクト
フォームデータを保存し、直前に支払いセクション
Order.find_byセクションにルーティング、現在のユーザーに関連付け。注文は何によってわかりますか?
背景: Railsの4 PostgreSQLの 工夫宝石
class OrdersController < ApplicationController
before_action :authenticate_user!, :except => [:step_1,:process_step1,:step_2a,:process_step_2a, :step_2b, :step_2c, :step_3]
def step_1
@order = Order.find_by id: session[:order_id]
if @order.nil?
@order=Order.new
@order.save!
end
end
def process_step1
order = Order.find_by id: session[:order_id]
order.update_attributes(order_params)
if (order.building == 'Residential') || (order.building == 'Commercial')
redirect_to step_2a_path
elsif (order.building == 'Commercial + Parking') || (order.building == 'Residential + Parking')
redirect_to step_2b_path
else
redirect_to step_2c_path
end
end
def step_2a
@order = Order.find_by id: params[:session_id]
end
def process_step_2a
order= Order.find_by status: 'cart'
# , user_id: current_user.id
order.update_attributes(order_params)
if order.save
redirect_to step_3_path
end
end
def step_2b
@order= Order.find_by status:'cart'
# , user_id: current_user.id
end
def process_step_2b
order= Order.find_by status: 'cart'
# , user_id: current_user.id
order.update_attributes(order_params)
if order.save
redirect_to step_3_path
end
end
def step_2c
@order= Order.find_by status:'cart'
# , user_id: current_user.id
end
def process_step_2c
order= Order.find_by status: 'cart'
order.update_attributes(order_params)
if order.save
redirect_to step_3_path
end
end
def step_3
@order= Order.find_by status:'cart'
# , user_id: current_user.id
end
def process_step_3
order= Order.find_by status: 'cart', user_id: current_user.id
order.update_attributes(order_params)
if order.save
redirect_to payment_path
end
end
def payment
@order= Order.find_by status:'cart', user_id: current_user.id
end