Reputation: 401
I'm following Hartl's Ruby Tutorial. I'm on the beginning of chapter 5. The instructions are to add an image ('rails.png') via
<%= link_to image_tag("rails.png", alt: "Rails logo"),
'http://rubyonrails.org/' %>
to the home page at: app/views/static_pages/home.html.erb
The image is downloaded via
$ curl -O http://rubyonrails.org/images/rails.png
$ mv rails.png app/assets/images/
However I am receiving an error on the asset precompile. I have no context on how to go about fixing this. So if there's extra info necessary to help solve this problem, let me know so I can add it! This is the text of the error page of localhost:3000.
Sprockets::Rails::Helper::AssetNotPrecompiled in StaticPagesController#home Asset was not declared to be precompiled in production. Add
Rails.application.config.assets.precompile += %w( rails.png )
toconfig/initializers/assets.rb
and restart your serverExtracted source (around line #350): def raise_unless_precompiled_asset(path) raise Helper::AssetNotPrecompiled.new(path) unless precompiled?(path) end end end
Edit : Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem 'bcrypt', '3.1.7'
gem 'faker', '1.4.2'
gem 'carrierwave', '0.10.0'
gem 'mini_magick', '3.8.0'
gem 'fog', '1.36.0'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end
Upvotes: 1
Views: 561
Reputation: 1155
I've encountered similar issue a while ago and I've fixed it by adding .png files to precompiled assets. Just try updating your config/application.rb file with following line:
config.assets.precompile += %w(.png)
Please remember about re-starting your Rails server afterwards ;)
Upvotes: 3