Skip to content

Instantly share code, notes, and snippets.

@philsmy
Created August 8, 2021 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save philsmy/e5de9b16279300f30ae8a6286ce05fdb to your computer and use it in GitHub Desktop.
Save philsmy/e5de9b16279300f30ae8a6286ce05fdb to your computer and use it in GitHub Desktop.
Debugging Ruby on Rails Cheatsheet

This is the companion to my YouTube video: https://youtu.be/MJSZ3WcgHeE

Debugging Rails in Development

1. Basic

https://guides.rubyonrails.org/debugging_rails_applications.html

  • Putting debug info into views using debug helper (or to_yaml or inspect)
<% if Rails.env.development? %>
    <div class='row'>
    <div class='col'>
    <%= time_tracker %>
    </div>
    </div>
  <% end %>
logfile = File.open(Rails.root.join('log/order_task_logger.log'), 'a') # create log file
logfile.sync = true # automatically flushes data to file
TASKS_LOGGER = Logger.new(logfile) # constant accessible anywhere
TASKS_LOGGER.level = Rails.env.development? ? Logger::DEBUG : Logger::WARN

2. Intermediate (gems)

2a. Memory Gems

Not my area of expertise!

TIP: To run production on your machine with postgres change the database.yml

3. Low Level

##4. VSCode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment