Upgrade to Pro — share decks privately, control downloads, hide ads and more …

5 Random Ruby Tips

5 Random Ruby Tips

This was a short talk given for the August edition of the Ruby SG meetup(https://www.meetup.com/Singapore-Ruby-Group/events/242357204/) at Rakuten Viki.

Mohnish G J

August 29, 2017
Tweet

More Decks by Mohnish G J

Other Decks in Programming

Transcript

  1. play -I Why this command? • A way to type

    or copy paste less and debug faster What does this pry command do? • Replay code from files & methods as if they were entered directly in the Pry REPL How to use this command? • To execute a single line of code: play -l 32 • To execute multiple lines of code: play -l 32..35 Bonus The command is very easy to remember!
  2. Why this command? • You’ve debugged your problem • Wish

    the program to run to the end disable-pry What does this pry command do? Once this command is run • Any further calls to pry return nil • The program flow will not be interrupted How to use this command? • disable-pry The Catch!
  3. Why this command? • Scenario ◦ Parsing process can go

    wrong while entering a multi-line expression ◦ The read loop will never terminate • Command will ◦ Enable normal input to resume without having to restart the server What does this pry command do? • Clears the input buffer and breaks out of the read loop • Allows normal input to resume on the next line How to use this command? • ! yes, that’s it :) !
  4. To quit an IRB session • Command: alias q exit

    To require a file/library in IRB • Command: alias re require To relatively require a file/library in IRB • Command: alias rer require_relative Handy aliases one could add in their .irbrc
  5. Why? • It’s easier than to remember/look up these options

    when creating a new rails app • You no more have to explicitly specify them like - rails new new_app_name --skip-test --skip-turbolinks --database=postgresql Leveraging defaults for a new rails app through options defined in .railsrc How? • Edit your .railsrc file and add the following commands ◦ To use Postgres DB: --database=postgresql ◦ Skip test unit: --skip-test ◦ Skip Turbolinks: --skip-turbolinks • Place the .railsrc file in the home directory of your computer