【问题标题】:Bad URI on rails javascript_include_tag and stylesheet_link_tagRails javascript_include_tag 和 stylesheet_link_tag 上的错误 URI
【发布时间】:2018-01-16 17:50:12
【问题描述】:

所以我从这个项目中抽出几个月的时间,今天去了它并尝试托管它,但没有触及任何东西,我在指向我的 javascript 和 css 的两个链接上遇到了错误的 URI 错误。

<%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>

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

这是导致错误的两段代码。有谁知道问题可能是什么,我尝试了双引号/单引号的所有组合,但无济于事。

任何帮助将不胜感激!

编辑:

Application.js:

    // This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require jquery-ui




$(window).scroll(function() {
    var distanceFromTop = $(this).scrollTop();
    if (distanceFromTop >= $('.navbar').height()) {
        $('#sticky').fadeIn('1000').addClass('fixed');
    } else {
        $('#sticky').removeClass('fixed');
    }
});



$(document).ready(function() {
    $(".dropdown-toggle").dropdown();
});

应用程序.css

    /*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *
 *= require_tree .
 *= require_self
 *= require jquery-ui
 */

body {
    font-family: sans-serif;
    background-color: white;
    color: #686868;
}

@media (min-width: 768px) and (max-width: 991px) {
    .navbar-collapse.collapse {
        display: none !important;
    }
    .navbar-collapse.collapse.in {
        display: block !important;
    }
    .navbar-header .collapse, .navbar-toggle {
        display:block !important;
    }
    .navbar-header {
        float:none;
    }




}



* {
    border-radius: 0;
}

.navbar{
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0;
}

.navbar .navbar-nav {
    display: inline-block;
    float: none;
    vertical-align: top;
    margin-left: auto;
    padding: 0;
}

.navbar .navbar-collapse {
    text-align: center;
    border-radius: 0;
}

a {
    color: #1b7b90;
}

a:hover {
    color: #1b7b90;
    text-decoration: none;
}

hr {
    border: 0;
    height: 1px;
    background: #333;
    background-image: linear-gradient(to right, #ccc, #333, #ccc);
}

.property-link:hover {
    color: white;
}

.property-fixedbar {
    color: white;
    text-align: center;
    border-style: solid;
    border-width: 1px;
    border-color: white;
    margin-top: 12px;
    padding-top: auto;
}

.property-fixedbar:hover {
    color: #1b7b90;
    background-color: white;
}

.main-content {
    color: #686868;
}

.search-button:hover {
    background-color: black;
}

.table th{
    text-align: center;
}

#sticky {
    z-index: 10;
    height: 67px;
}


#sticky.fixed {
    display: block;
    position: fixed;
    top: 0;
    width: 100%;
}

.navBar-wrapper {
    height: 67px;
}

@media (min-width: 10px) and (max-width: 991px) {
    .navBar-wrapper {
        height: 150px;
    }

    #sticky {
        height: 100px;
    }

    #show-top {
        height: 180px;
    }

    #sticky.fixed {
        position: relative;
    }

    .fixed-summary {
        position: absolute;
        margin: 0;
    }
    .thumbnail-images {
        display: none;
    }
}

.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
    margin: auto;
}

#myCarousel {
    margin-left: 30px;
    margin-right: 30px;
}

.carousel-control {
    padding-top: 25%;
}
.carousel-control.left, .carousel-control.right {
    background: none;
    color: #1b7b90;
    border: none;
}

.hide-bullets {
    list-style:none;
    margin-left: 0;
    margin-top:20px;
}

.thumbnail {
    padding: 0;
}

.carousel-inner>.item>img, .carousel-inner>.item>a>img {
    width: 100%;
}

.green {
    color: green;
}

.red {
    color: red;
}

【问题讨论】:

  • 具体错误是什么?
  • 错误 URI(不是 URI?):file-digest:///Users/Sion/Google Drive/Projects/Accent_properties/app/assets/config/jquery-ui
  • 可能是您的 application.css 或 js 内部的问题。请发布这些文件。
  • 现在作为编辑添加
  • 尝试将 require jquery-ui 移到 require 树之上。行。

标签: ruby-on-rails ruby ruby-on-rails-5


【解决方案1】:

我遇到了完全相同的错误,这让我发疯了。

我猜这与 URI 有关(呃!),我终于将我的项目文件夹从 Google Drive 移到我的桌面,运行 bundle、rails db:migrate、rails assets:precompile 然后 rails s .原来这为我解决了问题。

【讨论】:

    猜你喜欢
    • 2012-03-19
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    • 2012-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多