DEV Community

Discussion on: Smarter Rails Services with Active Model Modules

Collapse
 
paulmakepeace profile image
Paul Makepeace

I'm curious why run_callbacks isn't wrapping the contents of #create_purchase as well?

In the ProductQualityValidator there's product.id; did you mean product_data[:id]? The where should be find_by to get a single object back.

Great article! One of the more convincing takes on Ruby service objects for Rails. The callbacks do feel pretty clunky though.

Collapse
 
sophiedebenedetto profile image
Sophie DeBenedetto

Hi there,

Ah yes run_callbacks should absolutely be used in the #create_purchase method! Thanks for bringing that up. The post has been update to reflect that, along with your suggestions for the ProductQualityValidator. Thanks!