【发布时间】:2015-04-21 17:39:46
【问题描述】:
当我尝试查看任何页面时,我收到上述错误。
这是我的 layouts/application.html.erb 代码:
<body>
<%= link_to "Store Front", root_path, id: "logo" %>
<div class="container">
<div class="row">
<aside class="span4">
</aside>
</div>
<%= yield %>
<%= render 'layouts/header' %>
<div class="container">
<div class="row">
<div class="span8">
<%= yield %>
</div>
<aside class="span4">
<%= render @cart %>
</aside>
<%= render 'layouts/footer' %>
</div>
</body>
问题是由 引起的。
这是我的 application_controller :
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
helper_method :current_order
private
def current_cart
Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
cart
end
end
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails