Ahmad Al-kheat Ahmad Al-kheat - 1 year ago 73
React JSX Question

React not reaching static images in a Rails stack on heroku

I have a rails app with react, I have a simple img tag in one of my components:

render: function(){
return (
<img src='/assets/avatar-50.png' alt='profile pic' className='img-circle' />

This works in development, but in production the image is not available, what am I missing?


Answer Source

while you have not specified the version of rails you are using, but i would assume that it has asset-compilation with digests. so production image-urls will actually look different than in local development. that is why you need to use helper methods like image_url in order to reference them. read more about this topic in the guides: http://guides.rubyonrails.org/v4.2/asset_pipeline.html#in-production

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download