2017-06-14 113 views
2

今天我需要你的帮助,当我尝试安装Bootstrap时发现了一个奇怪的错误。我一直在寻找网络,所以我似乎无法找到正确的答案来解决我的问题......如果有解决方案(真的搜索答应!),那么我很抱歉。这里的错误消息:Devise - Bootstrap - RoR:Sprockets :: Rails :: Helper :: AssetNotFound in Devise :: Sessions#new

Showing /PATH/app/views/layouts/application.html.erb where line #14 raised: 

The asset "apple-touch-icon-144x144-precomposed.png" is not present in the asset pipeline. 
Extracted source (around line #14): 

    <!-- For third-generation iPad with high-resolution Retina display: --> 
    <!-- Size should be 144 x 144 pixels --> 
    <%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %> 

    <!-- For iPhone with high-resolution Retina display: --> 
    <!-- Size should be 114 x 114 pixels --> 

Rails.root: /PATH 

所有我到现在为止在项目中创建它,将制定并试图安装宝石“Twitter的引导护栏”和应用的布局,但我得到这个错误。 这里是我的github上的链接:https://github.com/Ardzii/finance-tracker

这里是我特别编辑的文件:

宝石文件:

source 'https://rubygems.org' 

git_source(:github) do |repo_name| 
    repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 
    "https://github.com/#{repo_name}.git" 
end 


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '~> 5.1.1' 
gem 'devise' 
gem 'twitter-bootstrap-rails' 
gem 'devise-bootstrap-views' 
gem 'sprockets-rails', :require => 'sprockets/railtie' 
gem 'jquery-rails' 
# Use Puma as the app server 
gem 'puma', '~> 3.7' 
# Use SCSS for stylesheets 
gem 'sass-rails', '~> 5.0' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# See https://github.com/rails/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use CoffeeScript for .coffee assets and views 
gem 'coffee-rails', '~> 4.2' 
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 
gem 'turbolinks', '~> 5' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.5' 
# Use Redis adapter to run Action Cable in production 
# gem 'redis', '~> 3.0' 
# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

group :development, :test do 
    gem 'sqlite3' 
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 
    # Adds support for Capybara system testing and selenium driver 
    gem 'capybara', '~> 2.13' 
    gem 'selenium-webdriver' 
end 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 
    gem 'web-console', '>= 3.3.0' 
    gem 'listen', '>= 3.0.5', '< 3.2' 
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 
    gem 'spring' 
    gem 'spring-watcher-listen', '~> 2.0.0' 
end 

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 

group :production do 
    gem 'pg' 
    gem 'rails_12factor' 
end 

application.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, 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 devise_bootstrap_views 
*= require_tree . 
*= require_self 
*/ 

路由f ILE:

Rails.application.routes.draw do 
    devise_for :users 
    # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 
    root 'welcome#index' 
end 

而在我做的终端:

$rails g bootstrap:install static 
$rails g bootstrap:layout application 
and overrode the application.html.erb 
$rails g devise:views:locale en 
$rails g devise:views:bootstrap_templates 

*****编辑:添加application.html.erb FILE(由自举产生)****** *

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title><%= content_for?(:title) ? yield(:title) : "FinanceTracker" %></title> 
    <%= csrf_meta_tags %> 

    <%= stylesheet_link_tag "application", :media => "all" %> 

    <!-- For third-generation iPad with high-resolution Retina display: --> 
    <!-- Size should be 144 x 144 pixels --> 
    <%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %> 

    <!-- For iPhone with high-resolution Retina display: --> 
    <!-- Size should be 114 x 114 pixels --> 
    <%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %> 

    <!-- For first- and second-generation iPad: --> 
    <!-- Size should be 72 x 72 pixels --> 
    <%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %> 

    <!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: --> 
    <!-- Size should be 57 x 57 pixels --> 
    <%= favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %> 

    <!-- For all other devices --> 
    <!-- Size should be 32 x 32 pixels --> 
    <%= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' %> 

    <%= javascript_include_tag "application" %> 

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> 
    <!--[if lt IE 9]> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js" type="text/javascript"></script> 
    <![endif]--> 
    </head> 
    <body> 

    <div class="navbar navbar-default navbar-static-top"> 
     <div class="container"> 
     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse"> 
      <span class="icon-bar"></span> 
      <span class="icon-bar"></span> 
      <span class="icon-bar"></span> 
     </button> 
     <a class="navbar-brand" href="#">FinanceTracker</a> 
     <div class="navbar-collapse collapse navbar-responsive-collapse"> 
      <ul class="nav navbar-nav"> 
      <li><%= link_to "Link1", "/path1" %></li> 
      <li><%= link_to "Link2", "/path2" %></li> 
      <li><%= link_to "Link3", "/path3" %></li> 
      </ul> 
     </div> 
     </div> 
    </div> 

    <div class="container"> 
     <div class="row"> 
     <div class="col-lg-9"> 
      <%= bootstrap_flash %> 
      <%= yield %> 
     </div> 
     <div class="col-lg-3"> 
      <div class="well sidebar-nav"> 
      <h3>Sidebar</h3> 
      <ul class="nav nav-list"> 
       <li class="nav-header">Sidebar</li> 
       <li><%= link_to "Link1", "/path1" %></li> 
       <li><%= link_to "Link2", "/path2" %></li> 
       <li><%= link_to "Link3", "/path3" %></li> 
      </ul> 
      </div><!--/.well --> 
     </div><!--/span--> 
     </div><!--/row--> 

     <footer> 
     <p>&copy; Company 2017</p> 
     </footer> 

    </div> <!-- /container --> 

    </body> 
</html> 

在此先感谢!

+0

你在哪里存储图像'apple-touch-icon-144x144-precomposed.png'?我无法在您的项目中找到它。我真的不认为这与Devise有什么关系。我认为rails找不到那个特定的.png图像,因为它不存在。 – Belder

+0

我在'app/assets/images'中看到了一些文件,在你的'public'文件夹中,但是你需要的'.png'图像并不是真实的。 – Belder

+0

嘿,布兰登!非常感谢您的快速回答......我只是感到惊讶,它不在那里!最后,我只是将一些引导主题应用于所有这些! 虽然我的理解是,我执行的'generate'命令会照顾它吗? – Ardzii

回答

2

这似乎不是一个设计问题。它看起来像是图像apple-touch-icon-144x144-precomposed.png实际上并不存在于您的项目中。 Rails因为无法找到它而抛出一个错误。

rails无法找到的apple-touch-icon-144x144-precomposed.png来自bootstrap主题。这些图像应该位于您下载的主题的文件夹中(除非您以某种方式删除了原件......那么您将不得不再次下载它)。如果你不需要这些图像,你可以从你的html布局的<head>中删除所有的图标链接标签,错误将会消失。

- 或 -

您可以使用图标生成器来创建你想要的那些,并将它们保存与特定的文件名(在你的情况:apple-touch-icon-144x144-precomposed.png)到您的项目和错误便会自行消失为好。但再一次,如果你不需要它们,那么这样做没有意义。

老实说,我不知道为什么你遇到这个问题,如果你没有改变从主题的原始文件,但你应该阅读THIS & THIS,看它是否有助于澄清事情。

希望能帮助&祝你的项目顺利!