-1
我正在製作一個軌道倉庫應用程序。用戶選擇要購買的物品並繼續結帳後,我想保存它們的訂單。如果保存失敗,我想重定向到索引。 如果保存成功,則應清除session[:cart]
。然後將用戶重定向到目錄頁面(索引操作)。路線問題? Rails'倉庫'問題與save_order重定向
def save_order
@cart = find_cart
@order = Order.new(params[:order])
if @order.save
session[:cart] = nil
redirect_to :action => 「index」
else
redirect_to :action => 「index」
end
end
如果如果爲了節省包括行redirect_to :action => 「index」
,我只是得到對鉻"We're sorry, but something went wrong"
。
如果我把它拿出來,我得到
Template is missing
Missing template store/save_order, application/save_order with {:locale=>[:en],
:formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "I:/13141-
CSC340A/Rails/Sites/depot3/app/views"
任何想法?
Depot::Application.routes.draw do
resources :orders
的routes.rb
get "store/index"
post "store/add_to_cart"
post "store/empty_cart"
post "store/save_order"
post "store/checkout"
resources :products
同意。嘗試用智能引號替換雙引號或單引號。編譯時,智能引用幾乎一致地引起混亂。 – zeantsoi
甚至符號。 – pduersteler