Rails refactoring has_many I have a RoR 4 app, and its model have these associations:

has_many :accreditations
has_one :legal, -&gt; { where(kind_cd: Accreditation.legal) }, class_name: 'Accreditation'
has_many :departments, -&gt; { where(kind_cd: Accreditation.department) }, class_name: 'Accreditation'


So, you see that these associations similar, but legal &amp; departments have more conditions than accreditations. Can I replace class_name: 'Accreditation' with something like using :accreditations?
There are two ways to tackle this situation. One of them is what you did: follow the Law of Demeter; I don't have any advice to improve your code. The second way is move the logic to the other model. In that case you'd write:

class Company
  has_many :accreditations
end

class Accreditation
  scope :departments, where(kind_cd: department)

  def self.legal
    where(kind_cd: legal).first
  end
end


Both are ok even though I prefer the second because the logic of departments/legal is within the accreditation model.