Refactoring has_many with scopes
I'm a newbie and I just showed my code to an expert, that told me I shouldn't use has_many to filter my variables, but scopes . I have three models : User, Product and Ownership. So here is my code in app/models/user.rb : class User has_many :ownerships, foreign_key: "offerer_id", dependent: :destroy has_many :owned_products, through: :ownerships, source: :product has_many :future_ownerships, -> { where owning_date: nil, giving_date: nil }, class_name: "Ownership", foreign_key: "offerer_id" has_many :wanted_products, through: :future_ownerships, source: :product end So I deleted the has_many