ruby on rails - Law of Demeter in `includes` and `group` queries -
how can apply law of demeter on code?
i know how creating separate methods, scope.... i'm not sure how queries this.
pages = seo::page.active .path_with(category) .includes(seo_area: :suburb) .group('suburbs.state')
scope :path_with, -> category { where('path ?', "/#{category}/%") }
you can create class-methods or new scopes encapsulate logic in seo::page
class.
def self.grouped(category) active .path_with(category) .includes(seo_area: :suburb) .group('suburbs.state') end pages = seo::page.grouped(category)
Comments
Post a Comment