by alokrai on 9/16/21, 10:58 PM with 63 comments
by gscho on 9/17/21, 1:50 AM
by gouda-gouda on 9/17/21, 6:01 AM
When it comes to building feature-rich web applications quickly and sanely, Ruby is still hard to beat IMO.
by pqdbr on 9/17/21, 2:07 PM
I use it extensively to avoid duplicating scope code.
For instance:
class Listing
scope :active, -> { where("expired_at > ?", Date.current).where.not(suspended: true) }
endclass User
has_many :listings
endSo instead of doing this (which is terrible):
user.joins(:listings).distinct.where("listings.expired_at > ? AND listings.suspended != FALSE", Date.current)
You can simply:
user.joins(:listings).distinct.merge(Listing.active)
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.
by Toutouxc on 9/17/21, 8:25 AM
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).
by gsinkin on 9/17/21, 12:42 PM
Also, I appreciate the Rails love.
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.
by elesbao on 9/17/21, 12:27 PM
by moffkalast on 9/17/21, 9:47 AM