My rails app in dev mode works and looks exactly as I want it to, but in production it looks different on chrome and safari, in safari the logo images loads but not the font, in chrome the font loads but not the image plus the input fields are a little longer and mis-aligned in chrome but in dev mode it all looks great in chrome
I been messing with this for a while and deleted the public/assets a few times a did
rake assets:precompile RAILS_ENV=production
with no success, the precompile goes through with no errors
config/application.rb:
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.assets.paths << "#{Rails.root}/assets/fonts"
config.assets.paths << "#{Rails.root}/assets/images"
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.precompile += %w( .svg .eot .woff .ttf )
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.assets.enabled = true
#config.assets.paths << "#{Rails.root}/app/assets/fonts"
config/environments/production:
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
#config.assets.compile = true
config.assets.precompile = ['*.js', '*.css', '*.css.erb', '*.css.scss']
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
config.assets.paths << "#{Rails.root}/assets/fonts"
config.assets.paths << "#{Rails.root}/assets/images"
config.assets.precompile += %w( .svg .eot .woff .ttf )
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
In your config/environments/production.rb file, set:
config.serve_static_assets = false (currently it's set to true)
config.assets.compile = true (currently it's set to false)
This should solve your problem.
Let me explain what I am asking you to do.
By setting config.serve_static_assets = false, we are telling rails server, don't add ActionDispatch::Static middleware, which is used to serve static assets.
Why not?
That's because in production environment, you are expected to run your application server (like puma) behind a web server (like Apache/Nginx), which is designed to serve static files (including assets) directly, without bothering to send the request to rails application server.
Since, you are not using any web server, we are turning it off.
By setting config.assets.compile = true, we are telling rails to compile the requested asset at runtime. i.e. Look for the requested asset in app/assets, vendor/assets, lib/assets and serve it if found from any of these locations.
By default, config.assets.compile is true in development, false in production environment. Since, we are not using web server to serve static assets, we are asking rails to live compile our assets.
For further details refer to the asset pipeline documentation.
Related
I don't understand why heroku won't compile my assets. Down below is the content of my production.rb file
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.assets.initialize_on_precompile = false
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
# config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.serve_static_files = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
Also here is the content of my application.css file. I'am not using sass, I'am using multiple different css files and bootstrap 3.3.5 css file.
/*
* 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, vendor/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 styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require about
*= require bootstrap
*= require comment
*= require forms
*= require main
*= require navigation
*= require notices
*= require post
*= require_self
*/
Typical reason for this error is either that your CSS is invalid, or your commit is not being processed by Heroku correctly.
The simplest way to fix this error is to precompile locally and then push to the platform:
$ rake assets:clobber
$ rake assets:precompile RAILS_ENV=production
$ git add .
$ git commit -a -m "Assets"
$ git push heroku master
This will allow you to push a set of assets which Heroku will only have to update (not compile from scratch). If it doesn't work, you should post your logs of the buildpack so we can see what's going on.
Preprocessor
From looking at your code, the most important change you need to make is use of preprocessors (to call image_url):
#app/stylesheets/about.scss
.img-circle:hover {
background: image_url("founder-cartoon-pic.png");
}
You need to change all your own .css to .scss, and replace url(...) with image_url(...) - this will reference the correct image in production, even with asset fingerprinting.
The problem is that url for CSS is a static method - it calls an "absolute" path...
url(your-image.png) refers exclusively to assets/images/your-image.png
image_url(your-image.png) refers to the asset_path and calls only the correct file
Thus, the answer to your question is to make sure your assets are referenced with the appropriate asset_helpers -- meaning you'll have to use a preprocessor (SCSS / SASS).
I have been trying to work on my rails project since I precompiled the assets to deploy to Heroku. The css would not update, so I followed the advice of other similar entries and deleted the static file. The app would then never load, it would just be in a state of buffer. I have also tried to simply set the config.serve_static_files to false. After running a rake assets clean, I have the same result. I have also tried dscacheutil -flushcache, to not effect.
my development.rb file:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false
config.serve_static_files = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
config.assets.compress = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = false
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
And just in case my production.rb file:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
Please help me, I can hardly do any work like this. Thank you
Have you tried running rake assets:precompile?
Some trivia for you:
rake assets:clean
A better way to get rid of all precompiled assets is rake assets:clobber.
This actively removes the files and folders in your /public/assets folder, allowing you to get rid of any of the precompiled assets which may be left behind.
--
Another piece of trivia:
Whenever running rake assets:precompile, run it with an ENV var:
rake assets:precompile RAILS_ENV=production
This ensures the files are pre-compiled using the data & settings that are available in the production environment, thus giving you the most reliable files.
As my own rule, I always try and ensure local assets are loaded dynamically.
This requires no change on your part (indeed, I'd actually remove the serve_static_files line in your development.rb file).
The reason for this is that if you're dealing with precompiled assets in development, you're going to have to recompile them each time you want to test if they've changed, both time consuming and unreliable.
Heroku should only require asset precompilation for its production environment.
I cannot even run that it seems
This suggests a deeper problem, either with your app or Ruby installation.
There are several things you need to do to ensure this is not a major problem:
Remove all your CSS and JS to a temp folder (Recycle Bin if necessary), and then run rake assets:precompile. There may be an off reference/loop causing the problem
Create a new Rails app with rails new TESTAPP and then run rake assets:precompile immediately. If it works well, you know the problem is with your current app
Stop any other running processes. If you've got programs running which could impede the cmd, it's going to prevent it running smoothly.
If you used the likes of RubyInstaller to install your Ruby, you may wish to upgrade. If not, you may wish to upgrade anyway.
Ultimately, if your computer is processing rake commands extremely slowly, it suggests a major system issue. You need to make sure it works properly to ensure a smooth development cycle.
I'm upgrading an application to use the asset pipeline.
I've got the css assets compiling into an application css file but they not being found when I run the application in production mode with
RAILS_ENV=production bundle exec rails s
and I visit any page I get the correct output from the database but no styling and the log shows:
ActionController::RoutingError (No route matches [GET]
"/assets/default.scss-1a27c...f07c.css"):
Even though that file exists in public/assets
$ ls public/assets/def*
public/assets/default.scss-1a27c...f07c.css public/assets/default.scss.css
public/assets/default.scss-1a27c...f07c.css.gz public/assets/default.scss.css.gz
What do I need to change to get the server to find the asset file?
Same is happening for my other .css files. They get compiled into public/assets with finger prints but then are not found.
Page source is showing:
<link href="/assets/default.scss-1a27c...f07c.css"
media="screen" rel="stylesheet" type="text/css" />
The rails (haml) source is = stylesheet_link_tag 'default.scss.css'
public.assets curently includes has the following files.
$ ls public/assets/def*
public/assets/default.scss-1a27c22229b7b522066181f27af4f07c.css
public/assets/default.scss-1a27c22229b7b522066181f27af4f07c.css.gz
public/assets/default.scss.css
public/assets/default.scss.css.gz
application.rb has
$ cat config/application.rb
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module Linker
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.initialize_on_precompile = false # For Heroku
config.assets.version = '1.0'
end
end
config/environments/production has:
$ cat config/environments/production.rb
Linker::Application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.assets.precompile += ['default.scss.css','main.css', 'jquery-ui-1.8.22.custom.css']
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
end
This seems to be happening for all assets, e.g.
Started GET "/assets/default.scss-1a27c22229b7b522066181f27af4f07c.css" for 127.0.0.1 at 2014-02-23 10:24:47 -0500
ActionController::RoutingError (No route matches [GET] "/assets/default.scss-1a27c22229b7b522066181f27af4f07c.css"):
Started GET "/assets/main-6864687b4114a1c316e444bd90f233ff.css" for 127.0.0.1 at 2014-02-23 10:24:47 -0500
ActionController::RoutingError (No route matches [GET] "/assets/main-6864687b4114a1c316e444bd90f233ff.css"):
Started GET "/assets/jquery-ui-1.8.22.custom-24319b4b1218846a3fe22a0479ae98b4.css" for 127.0.0.1 at 2014-02-23 10:24:47 -0500
ActionController::RoutingError (No route matches [GET] "/assets/jquery-ui-1.8.22.custom-24319b4b1218846a3fe22a0479ae98b4.css"):
Started GET "/assets/application-fc1d492d730f2a45581a40eac4607db8.js" for 127.0.0.1 at 2014-02-23 10:24:47 -0500
ActionController::RoutingError (No route matches [GET] "/assets/application-fc1d492d730f2a45581a40eac4607db8.js"):
Started GET "/images/link.ico" for 127.0.0.1 at 2014-02-23 10:24:48 -0500
ActionController::RoutingError (No route matches [GET] "/images/link.ico"):
Rails by default doesn't serve assets under public. See your production.rb:
config.serve_static_assets = true
Change that to true and you're good to go. (Note: you don't want that to be true in production, remember to change it back before deploying!)
See Configuring Rails Applications for details.
In rails 6, in the default production.rb there should be a line
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
So run your server with
RAILS_SERVE_STATIC_FILES=true rails server -e production
or set config.public_file_server.enabled=true in production.rb. See answers below for rails 4 and 5.
The Rails 5 solution is similar to the Rails 4 solution given by Jules Copeland above.
In your pre-generated config/environments/production.rb file, there should be an entry that looks something like this:
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
I found a decent explanation for this setting in the Configuring Rails Applications guide at http://guides.rubyonrails.org:
config.public_file_server.enabled configures Rails to serve static
files from the public directory. This option defaults to true, but in
the production environment it is set to false because the server
software (e.g. NGINX or Apache) used to run the application should
serve static files instead. If you are running or testing your app in
production mode using WEBrick (it is not recommended to use WEBrick in
production) set the option to true. Otherwise, you won't be able to
use page caching and request for files that exist under the public
directory.
Conclusion: In production, starting your rails server with RAILS_SERVE_STATIC_FILES=1 will allow Rails to serve any files in the public/assets directory just as a web server would. Keep in mind, Rails is an app server and will not do this as efficiently as a web server (e.g. NGINX, Apache, etc.). For real-world applications, you should have a dedicated web server sitting in front of Rails which will serve static assets by itself and only bother Rails for dynamic content as needed. For more details, see this article by Justin Weiss on the differences between web servers and app servers.
In Rails 4, you can get them to show in production (running locally), by passing an environment variable:
RAILS_SERVE_STATIC_FILES=true rails server -e production
This should work as long as you have this line in /config/environments/production.rb:
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
When you do rake assets:precompile, your assets go into public directory. See if you can find those files in public/assets/
You should see something like this:
I, [2014-02-23T20:06:21.853314 #26915] INFO -- : Writing app_root/public/assets/application-ecd8636fc80ea2b712039c4abc365da9.css
To cut a long story short, because I wasted enough time with this stupid framework.
I want to use pure CSS, no SCSS, no css.erb, no mumbo-jumpo that adds more overhead parsing, even if it is 2ms more.
My production.rb file has (I am using webrick):
Properties::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end
Now I have a simple css file under assets/stylesheets called general.css, and it contains this simple line:
html{
background-image:url('homepage_bg_1.jpg');
}
Now I have tried:
background-image:url('assets/homepage_bg_1.jpg');
background-image:url('public/assets/homepage_bg_1.jpg');
background-image:url('public/homepage_bg_1.jpg');
background-image:url('assets/images/homepage_bg_1.jpg');
Nothing works!! It browser still looks for a 'homepage_bg_1.jpg' image which is normal, but in my public assets folder I have 'homepage_bg_1-de4a0800c51d578f152fe5ca821136a6.jpg'.
I am using RAILS_ENV=production bundle exec rake assets:precompile to precompile my assets.
Now I would assume that Rails is not stupid enough, and will look for that file. But it doesnt. Can somebody just tell me what's wrong with this framework? Should I open an issue in Github? Is the framework trying to make us not use CSS?
If you don't want Rails to touch any of the assets you can put them in the public directory.
That way you won't have any fingerprinting or unwanted preprocessing. They will be served "as is". You don't have to mess with the Rails settings or do any precompilation.
And if you some day choose to use the asset pipeline again you can use both methods.
If you want to use fingerprinted assets in your stylesheets and javascript files you NEED preprocessing on those assets in order to use the asset pipeline helper methods. Rather than ranting and raving try and read the ever-so-informative guides.
You've rightly identified that your asset is compiled with a fingerprint, this is for asset expiry and is an integral part of the pipeline. In order to interpolate the correct filename to your other assets you need to use the helpers provided. For ERB use asset_path, and with Sass you have image-url/image-path/asset-url/asset-path/etc depending on your requirement.
Have you tried using the image helpers in your CSS for it to reference the digest version of your image?
Something like...
html {
background-image: image-url('homepage_bg_1.jpg');
}
This will put a reference to the image with the digest string appended to the name automatically for you.
My CSS won't change when I view it in the browser unless I precompile locally with rake assets:precompile.
Any ideas on how to remove this behavior? Do you need more files?
Here is my development.rb :
Mobile::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
end
Thanks!
Delete the public/assets folder. The files in the public/assets folder will be preferentially loaded over the ones that are in the app/assets folder.
Once deleted, you should be able to develop locally using the files in app/assets.