How to access server images from your Rails url

1

I want to access an image that I have in

assets/images/images.jpg or public/images/imagen.jpg from my server in production, example:

http://miservidor.com/images/imagen.jpg

and have my image.

    
asked by andrea paola vecino pastrana 09.07.2017 в 02:45
source

1 answer

1

To show images that are in the directory public you can request them directly, considering public as root; for example 1 :

<img src="/images/imagen.jpg" />

To get the image directly from your server, you could do it like this (as you show in your example):

http://miservidor.com/images/imagen.jpg

Instead, to show images that are in assets , you can use the helper image_tag ; for example:

<img src="<%= image_tag('/assets/images/image.jpg') %>" />

In this case you could not get the image through your browser as in the previous example.

1 In order to see the images directly (eg http://miservidor.com/images/imagen.jpg ) you must make sure you have the following line in the environments / production.rb :

config.serve_static_assets = true
    
answered by 09.07.2017 / 03:03
source