【问题标题】:Errors after installing bootstrap-sass on ruby rails在 ruby​​ rails 上安装 bootstrap-sass 后的错误
【发布时间】:2017-05-02 21:59:01
【问题描述】:

我正在尝试使用 rails 和 bootstrap-sass 创建一个 webapp。
我按照Ruby On Rails With Bootstrap Tutorial (simple) 的说明安装了那些,它有效。

安装 bootstrap-sass gem 并尝试在浏览器中打开我的应用程序后,ruby/rails 给我一个错误消息。

显示 C:/Sites/bopp/app/views/layouts/application.html.erb 其中第 7 行提出: TypeError: Das Objekt unterstützt dieese Eigenschaft oder Methode nicht.>

参赛作品:

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

根据Ruby on Rails Application coult not include stylesheet nor js我改了,又报错:

显示 C:/Sites/bopp/app/views/layouts/application.html.erb 其中第 7 行提出: 资产管道中不存在资产“default.css”。

条目:

<%= stylesheet_link_tag    "default", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "default", "data-turbolinks-track" => true %>

我将 application.css 更改为 application.css.scss。 条目:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
*
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 * It is generally better to create a new file per style scope.
 *
 *= require_tree .
 *= require_self
 */
@import 'bootstrap-sprockets';
@import 'bootstrap';

Gemfile 中只有一处更改:

gem 'bootstrap-sass'

我没有改变其他任何东西。

然后我跑了bundle install

Ruby 版本:2.3.3
Rails 版本:5.1.0(从http://railsinstaller.org/en下载)
操作系统:Windows 7
编辑器:Sublime Text 2
浏览器:Mozilla Firefox

【问题讨论】:

  • 也许有更多关于“对象不支持此属性或方法”的第一条消息的信息。也许应该是 layouts/application.html.erb 的文件名,特别是第 7 行的内容?

标签: ruby-on-rails ruby bootstrap-sass


【解决方案1】:

如果我没看错,您需要将默认设置更改为应用程序。

<%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>

它正在寻找一个 default.css 文件,但应该寻找您的 application.css 文件或您的 application.js 文件。通过改变你的第一个问题,你导致了你的第二个问题。

【讨论】:

  • 感谢您的回答,如果我将“默认”更改回“应用程序”(这是标准条目),我会收到第一个错误消息。正如我所提到的,我将其更改为“默认”,因为我在本网站的另一个答案中发现了这一点。第一个错误消息是关于属性和方法的,第二个是关于asset.css的。所以,我不知道该怎么做。
【解决方案2】:

我解决了这个问题。我不得不从 application.js 中删除 //= require_tree .

这里有答案:enter link description here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-27
    相关资源
    最近更新 更多