This is a bit off topic but I wanted to say I’m really glad there are still people out there hacking on some ruby + Postgres projects and writing about it. I feel that ruby is an excellent language and dread the demise of it.
Ruby is alive and well. We don’t use Rails specifically (Hanami + ROM.rb + DRY.rb), but absolutely love Ruby as a language and the ecosystem surrounding it. It’s productive, and as powerful as you need it to be.<p>When it comes to building feature-rich web applications quickly and sanely, Ruby is still hard to beat IMO.
Great article. By the way, ActiveRecord's #merge is golden, and I'm under the impression it's not as mainstream as it should be.<p>I use it extensively to avoid duplicating scope code.<p>For instance:<p>class Listing<p><pre><code> scope :active, -> { where("expired_at > ?", Date.current).where.not(suspended: true) }
</code></pre>
end<p>class User<p><pre><code> has_many :listings
</code></pre>
end<p>So instead of doing this (which is terrible):<p>user.joins(:listings).distinct.where("listings.expired_at > ? AND listings.suspended != FALSE", Date.current)<p>You can simply:<p>user.joins(:listings).distinct.merge(Listing.active)<p>Rails docs are amazing, but #merge doesn't get enough love. Maybe I'll issue a pull request to improve it with some examples like this and the ones from the article.
I love the section about getting rid of Active Record only to discover that the handwritten SQL equivalent is unmaintainable and slower.<p>Also if you're on the fat-models team and you have lots of behaviors and business logic on your models, it's often easier to just go with Active Record, because the second you wander off the beaten path (e.g. handwritten joins) you start dealing with weird franken-models that contain attributes from multiple tables, but not their behaviors (methods, callbacks).
Great post at the perfect time. I am currently wrestling with some gnarly, expensive queries in postgres and this gives me some great leads to try out.<p>Also, I appreciate the Rails love.<p>I know this is not a Who Is Hiring post, but if you are into Rails/Postgres and in the market (between UTC-4 and UTC-8 timezones), feel free to send me a note: gabe at instrumentl.com. We are doing some "biggish" data work helping nonprofits find grants and other fundraising opportunities.
Good post, well written, taught me a couple of things I didn't knew and uses Ruby in a clean way. I don't think it meant to be uber scalable but last time I had to build search in ruby I had to use Ferret (a great lib) and it was not this straightforward.