Rails production environment assets loading

In Gemfile add:

gem 'rails_12factor'

In config/environments/production.rb add

config.assets.compile = false #To stop run time assets precompile in production.
config.assets.digest = true  #To access assets which are precompiled and in their names have appendend digets by rails
config.cache_classes = true #allowing caching assets

In config/application.rb add

replace this

Bundler.require(:default, Rails.env)

with this

Bundler.require(:default, :assets, Rails.env)

Also add these lines

# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: ,
Posted in production, Ruby on Rails
One comment on “Rails production environment assets loading
  1. sethukarthik says:

    Thanks taimoor.changaiz, it is working fine for me now, but the images in not loading from assets. Please tell me is that any solution for this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: