I've been struggling with understanding the asset pipeline in Rails 4 for some time now. I managed to figure out how to pre-compile assets, but after deploying my application, the CSS stylesheet doesn't seem to be updating.
To confirm this, I checked Developer Tools and noticed that the source code looked different from my CSS files. My suspicion is that the issue lies within 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
Below is my Application.html.erb file containing 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
After running git add . (to add all files), I expected the latest stylesheet to be loaded as well. Unfortunately, it seems like Heroku did not update it.
This recurring issue is becoming frustrating, and I'm eager to find a solution for it.
Thank you for your attention.
Edit:
I believe I've identified the problem now. My stylesheets are not being updated in the public/assets folder. I'm unsure of what action to take to ensure they appear there.