[Terminal] Difference between irb and pry

It is a memorandum.

irb and pry

irb is an interactive shell originally built into a computer Can be used as a console in rails c.

pry is like an evolved version of irb By adding gem'pry-rails' to gemfile and bundling It can be used when executing the rails c command.

irb Display in a row

irb(main):002:0> Prefecture.all
=> #<ActiveHash::Relation:0x00007f97fef5c7e0 @klass=Prefecture, @all_records=[#<Prefecture:0x00007f97fef3e060 @attributes={:id=>0, :name=>"--"}>, #<Prefecture:0x00007f97fef3dd90 @attributes={:id=>1, :name=>"Hokkaido"}>, #<Prefecture:0x00007f97fef3da98 @attributes={:id=>2, :name=>"Aomori Prefecture"}>, #<Prefecture:0x00007f97fef3d7a0 @attributes={:id=>3, :name=>"Iwate Prefecture"}>, #<Prefecture:0x00007f97fef3d4d0 @attributes={:id=>4, :name=>"Miyagi Prefecture"}>, #<Prefecture:0x00007f97fef3d228 @attributes={:id=>5, :name=>"Akita"}>, #<Prefecture:0x00007f97fef3cf30 @attributes={:id=>6, :name=>"Yamagata Prefecture"}>, #<Prefecture:0x00007f97fef3cc88 @attributes={:id=>7, :name=>"Fukushima Prefecture"}>, #<Prefecture:0x00007f97fef3c968 @attributes={:id=>8, :name=>"Ibaraki Prefecture"}>, #<Prefecture:0x00007f97fef3c288 @attributes={:id=>9, :name=>"Tochigi Prefecture"}>, #<Prefecture:0x00007f97fef3c940 @attributes={:id=>10, :name=>"Gunma Prefecture"}>, #<Prefecture:0x00007f97fef6fcf0 @attributes={:id=>11, :name=>"Saitama"}>, #<Prefecture:0x00007f97fef6f908 @attributes={:id=>12, :name=>"Chiba"}>, #<Prefecture:0x00007f97fef6f5e8 @attributes={:id=>13, :name=>"Tokyo"}>, #<Prefecture:0x00007f97fef6f278 @attributes={:id=>14, :name=>"Kanagawa Prefecture"}>, #<Prefecture:0x00007f97fef6eee0 @attributes={:id=>15, :name=>"Niigata Prefecture"}>, #<Prefecture:0x00007f97fef6eaa8 @attributes={:id=>16, :name=>"Toyama Prefecture"}>, #<Prefecture:0x00007f97fef6e828 @attributes={:id=>17, :name=>"Ishikawa Prefecture"}>, #<Prefecture:0x00007f97fef6e558 @attributes={:id=>18, :name=>"Fukui prefecture"}>, #<Prefecture:0x00007f97fef6e288 @attributes={:id=>19, :name=>"Yamanashi Prefecture"}>, #<Prefecture:0x00007f97fef6df68 @attributes={:id=>20, :name=>"Nagano Prefecture"}>, #<Prefecture:0x00007f97fef6dc48 @attributes={:id=>21, :name=>"Gifu Prefecture"}>, #<Prefecture:0x00007f97fef6d978 @attributes={:id=>22, :name=>"Shizuoka Prefecture"}>, #<Prefecture:0x00007f97fef6d6a8 @attributes={:id=>23, :name=>"Aichi prefecture"}>, #<Prefecture:0x00007f97fef6d388 @attributes={:id=>24, :name=>"Mie Prefecture"}>, #<Prefecture:0x00007f97fef6d068 @attributes={:id=>25, :name=>"Shiga Prefecture"}>, #<Prefecture:0x00007f97fef6cd98 @attributes={:id=>26, :name=>"Kyoto"}>, #<Prefecture:0x00007f97fef6cac8 @attributes={:id=>27, :name=>"Osaka"}>, #<Prefecture:0x00007f97fef6c780 @attributes={:id=>28, :name=>"Hyogo prefecture"}>, #<Prefecture:0x00007f97fef6c320 @attributes={:id=>29, :name=>"Nara Prefecture"}>, #<Prefecture:0x00007f97fef5ff30 @attributes={:id=>30, :name=>"Wakayama Prefecture"}>, #<Prefecture:0x00007f97fef5fc60 @attributes={:id=>31, :name=>"Tottori prefecture"}>, #<Prefecture:0x00007f97fef5f940 @attributes={:id=>32, :name=>"Shimane Prefecture"}>, #<Prefecture:0x00007f97fef5f670 @attributes={:id=>33, :name=>"Okayama Prefecture"}>, #<Prefecture:0x00007f97fef5f3a0 @attributes={:id=>34, :name=>"Hiroshima Prefecture"}>, #<Prefecture:0x00007f97fef5f030 @attributes={:id=>35, :name=>"Yamaguchi Prefecture"}>, #<Prefecture:0x00007f97fef5ed60 @attributes={:id=>36, :name=>"Tokushima Prefecture"}>, #<Prefecture:0x00007f97fef5ea90 @attributes={:id=>37, :name=>"Kagawa Prefecture"}>, #<Prefecture:0x00007f97fef5e7c0 @attributes={:id=>38, :name=>"Ehime Prefecture"}>, #<Prefecture:0x00007f97fef5e400 @attributes={:id=>39, :name=>"Kochi Prefecture"}>, #<Prefecture:0x00007f97fef5e180 @attributes={:id=>40, :name=>"Fukuoka Prefecture"}>, #<Prefecture:0x00007f97fef5deb0 @attributes={:id=>41, :name=>"Saga Prefecture"}>, #<Prefecture:0x00007f97fef5dc30 @attributes={:id=>42, :name=>"Nagasaki Prefecture"}>, #<Prefecture:0x00007f97fef5d820 @attributes={:id=>43, :name=>"Kumamoto Prefecture"}>, #<Prefecture:0x00007f97fef5d5a0 @attributes={:id=>44, :name=>"Oita Prefecture"}>, #<Prefecture:0x00007f97fef5d2d0 @attributes={:id=>45, :name=>"Miyazaki prefecture"}>, #<Prefecture:0x00007f97fef5d050 @attributes={:id=>46, :name=>"Kagoshima prefecture"}>, #<Prefecture:0x00007f97fef5cc90 @attributes={:id=>47, :name=>"Okinawa Prefecture"}>], @query_hash={}, @records_dirty=false>

pry

Displayed with line breaks for each id (name)

[1] pry(main)> Prefecture.all
=> #<ActiveHash::Relation:0x00007fd444e9e448
 @all_records=
  [#<Prefecture:0x00007fd4444dfb28 @attributes={:id=>0, :name=>"--"}>,
   #<Prefecture:0x00007fd4444df600 @attributes={:id=>1, :name=>"Hokkaido"}>,
   #<Prefecture:0x00007fd4444de8e0 @attributes={:id=>2, :name=>"Aomori Prefecture"}>,
   #<Prefecture:0x00007fd4444ddf30 @attributes={:id=>3, :name=>"Iwate Prefecture"}>,
   #<Prefecture:0x00007fd4444dda08 @attributes={:id=>4, :name=>"Miyagi Prefecture"}>,
   #<Prefecture:0x00007fd4444dd3f0 @attributes={:id=>5, :name=>"Akita"}>,
   #<Prefecture:0x00007fd4444dcbd0 @attributes={:id=>6, :name=>"Yamagata Prefecture"}>,
   #<Prefecture:0x00007fd447c16240 @attributes={:id=>7, :name=>"Fukushima Prefecture"}>,
   #<Prefecture:0x00007fd447c151d8 @attributes={:id=>8, :name=>"Ibaraki Prefecture"}>,
   #<Prefecture:0x00007fd447c14698 @attributes={:id=>9, :name=>"Tochigi Prefecture"}>,
   #<Prefecture:0x00007fd447c14210 @attributes={:id=>10, :name=>"Gunma Prefecture"}>,
   #<Prefecture:0x00007fd44834fde0 @attributes={:id=>11, :name=>"Saitama"}>,
   #<Prefecture:0x00007fd448356fc8 @attributes={:id=>12, :name=>"Chiba"}>,
   #<Prefecture:0x00007fd4483548b8 @attributes={:id=>13, :name=>"Tokyo"}>,
   #<Prefecture:0x00007fd44835e660 @attributes={:id=>14, :name=>"Kanagawa Prefecture"}>,
   #<Prefecture:0x00007fd44835dd28 @attributes={:id=>15, :name=>"Niigata Prefecture"}>,
   #<Prefecture:0x00007fd447c1e3f0 @attributes={:id=>16, :name=>"Toyama Prefecture"}>,
   #<Prefecture:0x00007fd447c1e0a8 @attributes={:id=>17, :name=>"Ishikawa Prefecture"}>,
   #<Prefecture:0x00007fd4483667c0 @attributes={:id=>18, :name=>"Fukui prefecture"}>,
   #<Prefecture:0x00007fd448366220 @attributes={:id=>19, :name=>"Yamanashi Prefecture"}>,
   #<Prefecture:0x00007fd448365de8 @attributes={:id=>20, :name=>"Nagano Prefecture"}>,
   #<Prefecture:0x00007fd448365820 @attributes={:id=>21, :name=>"Gifu Prefecture"}>,
   #<Prefecture:0x00007fd448365460 @attributes={:id=>22, :name=>"Shizuoka Prefecture"}>,
   #<Prefecture:0x00007fd448364fd8 @attributes={:id=>23, :name=>"Aichi prefecture"}>,
   #<Prefecture:0x00007fd448364880 @attributes={:id=>24, :name=>"Mie Prefecture"}>,
   #<Prefecture:0x00007fd4483641c8 @attributes={:id=>25, :name=>"Shiga Prefecture"}>,
   #<Prefecture:0x00007fd44836fe10 @attributes={:id=>26, :name=>"Kyoto"}>,
   #<Prefecture:0x00007fd44836f910 @attributes={:id=>27, :name=>"Osaka"}>,
   #<Prefecture:0x00007fd44836ee20 @attributes={:id=>28, :name=>"Hyogo prefecture"}>,
   #<Prefecture:0x00007fd44836e880 @attributes={:id=>29, :name=>"Nara Prefecture"}>,
   #<Prefecture:0x00007fd44836dc78 @attributes={:id=>30, :name=>"Wakayama Prefecture"}>,
   #<Prefecture:0x00007fd44836d890 @attributes={:id=>31, :name=>"Tottori prefecture"}>,
   #<Prefecture:0x00007fd44836d2c8 @attributes={:id=>32, :name=>"Shimane Prefecture"}>,
   #<Prefecture:0x00007fd44836caa8 @attributes={:id=>33, :name=>"Okayama Prefecture"}>,
   #<Prefecture:0x00007fd44836c440 @attributes={:id=>34, :name=>"Hiroshima Prefecture"}>,
   #<Prefecture:0x00007fd4444e7e18 @attributes={:id=>35, :name=>"Yamaguchi Prefecture"}>,
   #<Prefecture:0x00007fd4444e7788 @attributes={:id=>36, :name=>"Tokushima Prefecture"}>,
   #<Prefecture:0x00007fd4444e6fb8 @attributes={:id=>37, :name=>"Kagawa Prefecture"}>,
   #<Prefecture:0x00007fd4444e68b0 @attributes={:id=>38, :name=>"Ehime Prefecture"}>,
   #<Prefecture:0x00007fd4444e6220 @attributes={:id=>39, :name=>"Kochi Prefecture"}>,

Since it was executed in irb (default state) this time, when trying to output prefectures with active_hash, it was displayed side by side, but by enabling pry-rails, line breaks are made for each id (name). It was able to be displayed.

Recommended Posts

[Terminal] Difference between irb and pry
About the difference between irb and pry
Difference between vh and%
Difference between i ++ and ++ i
Difference between product and variant
Difference between redirect_to and render
[Java] Difference between == and equals
Rails: Difference between resources and resources
Difference between puts and print
Difference between redirect_to and render
Difference between CUI and GUI
Difference between variables and instance variables
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
Difference between ArrayList and LinkedList
Difference between render and redirect_to
Difference between List and ArrayList
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between interface and abstract class
Difference between == operator and equals method
[Java] Difference between Hashmap and HashTable
JavaServlet: Difference between executeQuery and executeUpdate
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Rough difference between RSpec and minitest
[Rails] Difference between find and find_by
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
[JAVA] Difference between abstract and interface
Difference between Thymeleaf @RestController and @Controller
Difference between Stream map and flatMap
[Java] Difference between array and ArrayList
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
[rails] Difference between redirect_to and render
[Android] Difference between finish (); and return;
Note: Difference between Ruby "p" and "puts"
[Memo] Difference between bundle install and update
Difference between Ruby instance variable and local variable
Difference between pop () and peek () in stack
[For beginners] Difference between Java and Kotlin
Difference between isEmpty and isBlank of StringUtils
Difference between getText () and getAttribute () in Selenium
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Difference between addPanel and presentModally of FloatingPanel
[Ruby] Difference between print, puts and p
[Java] Difference between Intstream range and rangeClosed
Difference between int and Integer in Java
[Rails] Difference between redirect_to and render [Beginner]
[Java] Understand the difference between List and Set
[iOS] Understand the difference between frame and bounds