路线问题?使用save_order重定向的Rails'depot'问题

时间:2013-12-10 07:43:22

标签: ruby-on-rails ruby redirect routes depot

我正在制作一个rails depot应用程序。在用户选择要购买的商品并继续结帐之后,我想保存他们的订单。如果保存失败,我想重定向到索引。 如果保存成功,则应清除session[:cart]。然后将用户重定向到目录页面(索引操作)。

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”,我只需在Chrome上获取"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

1 个答案:

答案 0 :(得分:0)

我感觉“index”周围的智能引号可能是一个问题。用普通报价替换它们。