Use images in Rails

Use images in Rails.

Put the image file you want to use in app / assets / images. In the html.haml file where you want to use the image

html.haml


= image_tag src= "/assets/sample.png ", size: "50x50"

Specify the background image with css in Rails.

Put the image file used as the background in app / assets / images. And in the css file

css


background: image-url("sample.png ");
background-size: cover;

Recommended Posts

Use images in Rails
Use multiple checkboxes in Rails6!
[Rails] Use cookies in API mode
Group_by in Rails
[Rails] Use jQuery
How to use custom helpers in rails
How to use MySQL in Rails tutorial
How to use credentials.yml.enc introduced in Rails 5.2
Use custom images in Amazon SageMaker Studio notebooks
Model association in Rails
Use java.time in Jackson
[Rails] How to use select boxes in Ransack
Disable turbolinks in Rails
CSRF measures in Rails
Use Interceptor in Spring
Use OpenCV in Java
^, $ in Rails regular expression
Use MouseListener in Processing
How to use JQuery in js.erb of Rails6
Use PostgreSQL in Scala
Understand migration in rails
Use PreparedStatement in Java
Split routes.rb in Rails6
[Rails] How to use PostgreSQL in Vagrant environment
Use pagy for pagination in your Rails app.
Implement markdown in Rails
I want to use a little icon in Rails
Implement user follow function in Rails (I use Ajax) ②
Implement user follow function in Rails (I use Ajax) ①
Beginners use ubuntu in windows to prepare rails environment
Get UserAgent in [Rails] controller
Implement application function in Rails
[rails] How to post images
Declarative transaction in Rails #ginzarb
Implement follow function in Rails
[Rails] Save images using carrierwave
[Rails] How to use enum
[Rails] How to use enum
Japaneseize using i18n with Rails
Implement LTI authentication in Rails
Use ruby variables in javascript.
Error in rails db: migrate
Rails Active_storage -Simplify saving images-
How to use rails join
Gem often used in Rails
Display Flash messages in Rails
Use multiple databases with Rails 6.0
View monthly calendar in Rails
Implement import process in Rails
[Rails] How to use validation
Use Redis Stream in Java
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
Rewrite Routes in Rails Engine
[Docker] Use whenever with Docker + Rails
[Rails] How to use Scope
Use your own classes in the lib directory with Rails6
[Rails] How to use gem "devise"
How to use Lombok in Spring
Use voice recognition function in Unity
[Rails] Keyword search in multiple tables