by Kevin Murphy
We love reading, watching, and listening to constantly update our skills and learn new perspectives. Here are some of the exciting pieces we learned from this month.
Rails 6 deprecates where.not as NOR & Rails 6.1 as NAND
ActiveRecord queries are often a large part of the day in the life of a Rails developer. Recently, we reached for them in order to select some records by leveraging where.not
with multiple attributes. However, when we ran the specs we received a warning stating that this implementation has been depreciated due to unapparent behavior related to the conditional logic involved. Previously, logical NOR was used when applying the clause with multiple attributes, but as of Rails 6.1 logical NAND will be used instead.
What does this mean for you? Well, if you want to select for multiple attributes you can either use NAND logic such as where("foo != 'Foo' OR bar != 'Bar'")
or you can chain separate where.not
statements for each attribute.
Rails 6.1 adds query method missing to find orphan records
Some of our work involves large amounts of interconnected data. When a record is "orphaned", meaning it loses its "parent" record, this new method gives us an expressive API for querying those orphaned records.
Modern CSS with Tailwind
This book is a great introduction to the Tailwind utility CSS framework, as well as a valuable reference guide if you're already familiar.
There's No Such Thing as a Free Gem
Come for the promise of how to build an OAuth flow; stay for the discussion on evaluating the impact of a build vs. buy vs. borrow decision. This reinforced a lot of the conclusions I came to when I asked at RailsConf 2019: I know I can, but should I?
React State Batch Update
Modern react components leverage functional patterns to remain flexible, while still tracking and making changes on state within themselves. We learned that react helps us out by batching these hook-based state update functions so that we do not render unecessarily, and always group these changes so that they are changed within a single re-render.
Why Pry is one of the most important tools a junior Rubyist can learn
We ❤️ using Pry. If this article convinces you to dig into it, we have some additional tips available as well.
The career-changing art of reading the docs
Poring through documentation in the heat of the moment can be a necessity. Pre-emptively consuming documentation requires time (and privilege), but can help you (and others) out of jams, either by being able to find the information required, or recall it without the docs.
Rails' hidden type system
Rails's Attributes API is a great abstraction for helping Rails' internals, but also is very helpful for coercing types out of input for non-ActiveRecord classes, for example from controller parameters.