This is a personal memo.
How to access the rails console of an application running with docker.
Run rails c
inside the docker container.
Terminal
##Check the name of the container you want to enter
docker ps
##Enter the container
docker exec -it container name/bin/bash
##open rails console
root@96913c74e902:/app# rails c
`Redis#exists(key)` will return an Integer by default in redis-rb 4.3. The option to explicitly disable this behaviour via `Redis.exists_returns_integer` will be removed in 5.0. You should use `exists?` instead.
Loading development environment (Rails 6.0.3.2)
irb(main):001:0>
The terminal changes in the order of local ($)-> docker (root @ 96913c74e902 :)-> rails (irb (main)).
irb is an interactive mode of rails. Abbreviation for Interactive Ruby.
ctrl + c
.python
##It cannot be removed if the end is other than 0 (it is considered to be in the middle of the expression)
irb(main):014:2> quit
irb(main):015:2> exit
irb(main):016:2>
##ctrl +Clear with c and then exit
irb(main):017:0> exit
For one line
irb(main):001:0> p "hello rails"
"hello rails"
=> "hello rails"
irb(main):002:0> 1+2
=> 3
For multiple lines
irb(main):015:0> for i in 1...11 do
irb(main):016:1* print "#{i} "
irb(main):017:1> end
1 2 3 4 5 6 7 8 9 10 => 1...11
Recommended Posts