Three Things I Learned This Week - October 28 2016
- Understanding dates, times, and timezones in Ruby and how it's applied in Rails is tricky. This is my go-to post when it comes to refreshing the details in my head. The lesson is to use
Time.zone everywhere. Note that Rubocop also recommends the
Time.zone methods, providing a nice way to catch missed instances.
- While debugging with pry, the
whereami command in pry prints out the code view. This is very helpful if you've recently outputed a screen's worth of data hiding what the next command would be. I use this almost daily.
- Ruby allows for including a module into a class through code. If you don't own the code that you need to modify in some way, this is a valuable trick. Now I don't have to fork a project just to get some minor additional functionality. For example:
Written by Alex Brinkman who lives and works in Denver, but plays in the mountains.