RailsCasts Pro episodes are now free!
Learn more or hide this
Resources
rails g squeel:initializer rails c
Product.where{released_at < 3.months.ago} Product.where{released_at.lt 3.months.ago} Product.where{released_at.lt(3.months.ago) & price.gt(20)} Product.where{released_at.lt(3.months.ago) | price.gt(20)}
def self.search(query) where do (released_at <= Time.zone.now) & ((discontinued_at == nil) | (discontinued_at > Time.zone.now)) & (stock >= my{low_stock}) & (name =~ "%#{query}%") end end def self.low_stock 2 end