Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Movie < ActiveRecord::Base
- has_many :reviews
- def inspect ; "#{title} (#{rating}) - #{release_date.strftime('%D')}" ; end
- scope :for_kids, :conditions => ['rating IN (:ratings)', :ratings => %w(G PG)]
- scope :with_good_reviews, lambda { |cutoff|
- joins(:reviews).
- group(:movie_id).
- having("AVG(reviews.potatoes) > #{cutoff}")
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment