2017-06-14 112 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,看它是否有助於澄清事情。

希望能幫助&祝你的項目順利!