Quick Tip to Clean Up Rails Logs

Every few months I use this command to empty each and every one of my test.log and development.log files in the src folder of my laptop:

find ~/src \
  -maxdepth 6 \
  -type f \
  -mindepth 1 \
  \( -name "test.log" -or -name "development.log" \) \
  -exec truncate -s 0 {} \;

It works by…

  1. Finding files that match the name
  2. Using the truncate command to reduce the size of the file to 0 bytes

Instead of typing it out each time, I’ve created a quick alias in my .bash_profile when my shell loads:

alias truncate_devlogs='find . -maxdepth 6 -type f -mindepth 1 \( -name "test.log" -or -name "development.log" \) -exec truncate -s 0 {} \;'

Then when I remember to do so, or I wrap up work on a project, a quick truncate_devlogs recoups disk space and makes me feel better.


Now read this

How to fix TypeError: Nil is not a Symbol or String

If you’re using the form helpers built into Rails (or a library like SimpleForm that’s built on top of them), you might run into a somewhat confusing error: TypeError: nil is not a symbol nor a string Usually this will originate from... Continue →