【问题标题】:Install twitter bootstrap theme into rails 4 app - Vendor/assets directory not found?将 twitter bootstrap 主题安装到 rails 4 应用程序 - 找不到供应商/资产目录?
【发布时间】:2014-05-21 04:09:55
【问题描述】:

我正在尝试将来自 wrapbootstrap.com 的主题安装到我的 rails 4.1 应用程序中。

我使用 rails 4 脚手架创建了一个新应用。然后我下载了包含 4 个目录和一个 index.html 文件的 zip 目录,并将它们放在我认为应该去的地方:

css 移至 vendor/assets/stylesheets,js 移至 vendor/assets/javascripts,font 移至 vendor/assets/fonts,img 移至 vendor/assets/images。

然后我将此代码添加给我app/assets/stylesheets 文件:

*= require_tree ../../../vendor/assets/stylesheets/.

将此代码添加到我的app/assets/javascripts 文件中:

//= require_tree ../../../vendor/assets/javascripts/.

此时,我假设我已准备好所需的所有文件,因此我将 index.html 复制到我的应用程序中,并将浏览器指向适当的视图。基本上我看到的只是纯文本 - css/javascript/image 文件没有按预期工作。

在查看我的谷歌 Chrome 开发者工具时,我看到了一堆与此类似的错误:

GET http://localhost:3000/vendor/assets/stylesheets/bootstrap.min.css 404 (Not Found)

为了让这个主题发挥作用,我在这里缺少什么?

编辑:

我的 html 文件看起来像这样,我需要这些文件:

<!-- Styles -->
        <!-- Bootstrap CSS -->
        <link href="../../../vendor/assets/stylesheets/bootstrap.min.css" rel="stylesheet">
        <!-- Font awesome CSS -->
        <link href="../../../vendor/assets/stylesheets/font-awesome.min.css" rel="stylesheet">
        <!-- Pretty Photo -->
        <link href="../../../vendor/assets/stylesheets/prettyPhoto.css" rel="stylesheet">
        <!-- Animate -->
        <link href="../../../vendor/assets/stylesheets/animate.min.css" rel="stylesheet">
        <!-- Custom CSS -->
        <link href="../../../vendor/assets/stylesheets/style.css" rel="stylesheet">

【问题讨论】:

  • 尝试运行生产环境......只是为了生成缩小的资产......然后再次尝试运行开发......以前和我一起工作过。
  • 不要将供应商路径放在href中,只需添加普通` `并在application.css文件中包含其他css `
  • @jbmyid 做到了。谢谢老兄,请随时发布答案,以便我给你信用。

标签: javascript css ruby-on-rails twitter-bootstrap


【解决方案1】:

不要将供应商路径放在href中,只需添加正常 &lt;%= stylesheet_link_tag 'application', media: 'all' %&gt; 并在 application.css 文件中包含其他 css`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 2017-01-08
    • 2013-10-12
    • 2018-09-18
    • 1970-01-01
    相关资源
    最近更新 更多