Mansi Shah
Mansi Shah

Reputation: 524

Assets loading issue on Rails 5 app with Heroku

I am facing asset loading issue in Rails 5 application deployed on Heroku.

App Configuration is,

ruby => ‘2.3.1’

rails => '~> 5.0.1'

When image is stored on path,

app/assets/home/image1.jpg

I am accessing it in view as,

= image_tag('/assets/home/image1.jpg’)

which is working properly in Development ENV, but not in Production ENV.

As per Heroku log,

ActionController::RoutingError (No route matches [GET] "/assets/home/image1.jpg")

If I am moving image directly to

app/assets/image1.jpg

then its working on Production ENV.

Please guide about it.

Thanks

Upvotes: 5

Views: 3912

Answers (1)

puneet18
puneet18

Reputation: 4427

It looks like you assets are not compile on heroku.

Follow below code:

config/environments/production.rb

config.assets.compile = true then run commands:

RAILS_ENV=production rake assets:precompile

then push all compiled files with menifest file to heroku.

Upvotes: 13

Related Questions