[RUBY] [Rails] We have summarized the storage locations and usage of developer and user images.

Image storage location

Use of the file to save Storage location
Files prepared by the developer app/assets/under images
File uploaded by the user Under public

When you want to call an image from HTML

html.erb



# app/assets/images/logo.For png
<%= image_tag 'logo.png' %>

<img src="/assets/logo.png " alt="" >

html.erb


# public/logo.For png
<%= image_tag '/logo.png' %>

When you want to call an image from Sass

python



// app/assets/images/logo.For png
h1 {
  background-image: image-url('logo.png')
}

Recommended Posts

[Rails] We have summarized the storage locations and usage of developer and user images.
[Rails] Differences and usage of each_with_index and each.with_index
Learn the rudimentary mechanism and usage of Gradle 4.4
We have extracted the best plastics of Dockerfile!
I summarized the display format of the JSON response of Rails
Verification of the relationship between Docker images and containers
I summarized the types and basics of Java exceptions
Change the storage quality of JPEG images in Java
[Rails 6] The save timing of active_strage images has been changed.
Rails: I've summarized the model and database for a moment.
Java beginners briefly summarized the behavior of Array and ArrayList