This has been a problem for me for a while now, but I still can't figure out how the asset pipeline works in Rails 4. I finally learned how to pre-compile assets, but once again after deployment, my CSS Stylesheet isn't getting updated.
I confirmed this by going to Developer Tools and viewing the source. It looks different from my CSS files. My guess is the problem lies in my production.rb file.
Production.rb
Games::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.assets.version = '1.0'
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
end
Application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module Games
class Application < Rails::Application
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
config.exceptions_app = self.routes
end
end
Here is my Application.html.erb file with the helpers.
<!DOCTYPE html>
<html>
<head>
<title><%= @title %></title>
<%= stylesheet_link_tag "application", media: "all",
"data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
<%= render 'layouts/footer' %>
</body>
</html>
Gem File
gem 'rails', '4.0.4'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '~> 4.0.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'sprockets-rails', '~> 2.0.0'
gem 'bootstrap-sass', '2.3.2.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
Here are the steps I've taken
heroku run rake assets:precompile RAILS_ENV=production
git add .
git commit
git push heroku master
Now, maybe I'm mistaken, but having run the git add . (meaning add all files) it should have loaded the latest stylesheet as well. But once again, it seems like Heroku failed.
This has happened before, and is getting annoying, so I would like to find an explanation for this.
Thank you for your time.
Edit:
I think I now know what the problem is. My stylesheets never get updated to my public/assets folder. I don't know what I can do to make them appear there.
See Question&Answers more detail:
os