Today I Learned

A Zero One initiative

Where clause with Association

TIL that you can use a where clause when defining model associations

class Foo < ActiveRecord::Base
  has_many :bars, -> {where(active: true)}
end
Looking for help? Each developer at Zero One has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.