Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Product < ActiveRecord::Base
has_many :suppliers, conditions: ["suppliers.status = ?", true]
end
# In Rails4, if you wish to use the same, you can use the below syntax:
class Product < ActiveRecord::Base
has_many :suppliers, -> { where("suppliers.status = ?", true) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment