3

I need your help today with a weird error that I get when trying to install Bootstrap with devise. I've been looking the web and SO but I can't seem to find a proper answer to my problem... If there is a solution out there (really searched promised!), then I'm sorry for the post. Here's the error message:

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

All I until now in the project is creating it, adding Devise and then trying to install the gem 'twitter-bootstrap-rails' and apply the layouts but I get this error. Here's a link to my github: https://github.com/Ardzii/finance-tracker

and here are the files that I edited particularly:

Gem file:

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
 */

routes file:

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

And in the terminal I did:

$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

***** EDIT: ADDING THE application.html.erb FILE (generated by Bootstrap) *******

<!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>

Thanks in advance!

Martin Carre
  • 1,157
  • 4
  • 20
  • 42
  • Where are you storing the image `apple-touch-icon-144x144-precomposed.png` ? I can't find it in your project. I really don't think that this has anything to do with Devise. I think rails can't find that specific .png image because it doesn't exist. – Belder Jun 14 '17 at 14:00
  • I see some files in your `app/assets/images` & in your `public` folders but the `.png` images you need aren't actual there. – Belder Jun 14 '17 at 14:19
  • Hey there Brandon! Thanks a lot for your quick answer... I'm just surprised it's not there! In the end, I'm just applying some bootstrap themes that pack all of this up! It was my understanding though that the `generates` commands I executed would take care of it? – Martin Carre Jun 14 '17 at 15:59
  • 1
    hmm..So if I understand you correctly, the `apple-touch-icon-144x144-precomposed.png` that rails cannot find is from a bootstrap theme? Those images should be in the folder of the theme that you downloaded (unless you somehow deleted the originals...then you would have to pay for another download). If you don't need those images anyway, you can just delete all of the favicon link tags from the `` of your html layout. – Belder Jun 14 '17 at 16:03
  • 1
    I just integrated a bootstrap theme into one of my rails projects for the first time. Took me a while to figure it all out, but it's a great way to learn about the Rails asset pipeline. – Belder Jun 14 '17 at 16:05
  • Hey Brandon! Thanks again for your great follow-up! To precise a little. The theme I am referring to is a free one. Normally and as far as I understand (but I'm pretty new to this) the command:`$rails g bootstrap:install static` should have installed everything up. Deleting the portion of the code as you suggest it makes everything work but I'm wondering, why would bootstrap even install the view like this if it's not going to provide the related images? – Martin Carre Jun 15 '17 at 07:26
  • Honestly, I don't have a good answer for that, but you should read [THIS](https://lodge.statamic.com/questions/1488-how-to-get-rid-of-apple-touch-iconpng-fl) & [THIS](https://stackoverflow.com/questions/12480497/why-am-i-getting-error-for-apple-touch-icon-precomposed-png/18256077#18256077) – Belder Jun 15 '17 at 12:29
  • Pretty sure you can use a favicon generator and save the created favicons with those specific file names (`apple-touch-icon-144x144-precomposed.png`, etc) into your project and the errors will go away as well. Again though...If you don't need them, then there's no point in doing that...I think. I'm no expert...not even close : ) – Belder Jun 15 '17 at 12:33
  • Hey Brandon! Thanks a lot for everything! Could you put your comment (the 4th one) as an answer so that I can choose it as the correct one? – Martin Carre Jun 19 '17 at 07:51
  • Kindly refer to this [devise-bootstrap-views issue](https://stackoverflow.com/a/56526204/10907720) – Anand Raja Jun 10 '19 at 12:16
  • Kindly check this [devise-bootstrap-views issue](https://stackoverflow.com/a/56526204/10907720) – Anand Raja Jun 10 '19 at 12:18

1 Answers1

4

This doesn't seem to be a Devise issue. It looks like the image apple-touch-icon-144x144-precomposed.png doesn't actually exist in your project. Rails is throwing you an error because it can't find it.

The apple-touch-icon-144x144-precomposed.png that rails cannot find is from the bootstrap theme. Those images should be in the folder of the theme that you downloaded (unless you somehow deleted the originals...then you would have to download it again). If you don't need those images anyway, you can just delete all of the favicon link tags from the <head> of your html layout and the error will go away.

-or-

You can use a favicon generator to create the ones you want and save them with those specific file names (in your case: apple-touch-icon-144x144-precomposed.png) into your project and the errors will go away as well. But once again, if you don't need them then there's no point in doing that.

Honestly, I'm not sure why you are encountering this issue if you didn't alter the original files from the theme, but you should read THIS & THIS to see if it helps clarify things.

Hope that helps & good luck with your project!

Belder
  • 768
  • 1
  • 10
  • 17