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'
Advertisements

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

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: