There are many times when debugging or reporting that you may need to count the number of records that a certain record may have associated with it. PostgreSQL provides you with the tools to do this efficiently
Long running queries can tie up database connections, eventually bogging down your app and causing it to come to a grinding halt. Thankfully you can leverage statement_timeout to cause long running queries to raise an error.
I use joins regularly in my day to day work both explicitly and implicitly. However I regularly forget which type of join does what so I've created this post to serve as a quick reference guide.
When you navigate using an anchor element inside a Turbo Frame the default behaviour is for Turbo to handle this and replace only the containing Turbo Frame from the matching one in the response. This post summarises how you can change the default behaviour to conditionally replace Turbo Frames.
The PaperTrail gem provides version tracking for your ActiveRecord models but the creation of version entries is skipped in the test environment. This post investigates how to turn on and test versioning for specific tests.
I recently encountered a quirk with programmatic form submissions and turbo streams whereby using the form.submit() function in a stimulus controller wouldn't cause Turbo to hook into the response. This is a short post on how I solved this issue.
It's fairly common when working on existing or legacy codebases to find models that have instance methods defined on them that return ActiveRecord::Relation collections. This post explains how this can be avoided to improve the performance of your application.
Choosing the correct method for counting collections in Rails can be confusing. In this post we weigh up the different options ActiveRecord offers us and pick the best tool for the job.
RSpec is a wonderful tool for testing regular ruby and ruby on rails applications. However as an application and its test suite grows larger it can become cumbersome to run an entire suite or even an enire file when you make a change. Even switching between your editor and terminal to execute your tests can become tiresome if you are regularly running your specs or practicing Test Driven Development. Guard allows you to automate this process.