On Tue, 23 Feb 2016, at 02:11 PM, Peter Morris wrote:

> Also, I dislike how MissingBasket is not a subclass of basket.

I can see why you might be, but I’d be quite happy with it.

To me it’s only important that it quacks like a duck, and given that this is 
ActiveRecord, I avoid subclassing at all costs. I wouldn’t want somebody coming 
along later to think they could call `#save` on `MissingBasket`.

Subclassing an AR object suggests that STI [1] is in the house, and that’s 
never a house you want to spend much time in.

[1] http://api.rubyonrails.org/classes/ActiveRecord/Inheritance.html

> And why not use Basket.where(id: id).first_or_initialize

Yeah, that is a good point in the context of the example.

-- 
You received this message because you are subscribed to the Google Groups 
"North West Ruby User Group (NWRUG)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
Visit this group at https://groups.google.com/group/nwrug-members.
For more options, visit https://groups.google.com/d/optout.

Reply via email to