我有一个基本的静态网页。
class StaticPagesController < ApplicationController
def home
end
end
还有一个只有标题的 home.html.erb 。这在开发中工作得很好,但在测试中
test "should get home" do
get :home
assert_response :success
assert_select "title","home | #{@base}"
end
因错误而失败
ActionView::Template::Error: ActionView::Template::Error: undefined method []' for nil:NilClass
它在 application.html.erb 中显示错误
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
这是显示为导致错误的行。是什么导致了这个问题?
当我删除 stylesheet_link_tag 时它起作用。
*= require_tree
*= require_self
@import "bootstrap-sprockets";
@import "bootstrap";
这是我的application.css。样式表目录中还有另外两个 scss 文件。
发现问题并修复它。但不明白为什么会发生。 Bootstrap必须移动到同一目录中的sass文件中并且没有错误。但为什么会发生这种情况呢?它正在开发中。