Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # BAD: details of computing review goodness is exposed to controller
- class MoviesController < ApplicationController
- def movies_with_good_reviews
- @movies = Movie.joins(:reviews).group(:movie_id).
- having('AVG(reviews.potatoes) > 3')
- end
- def movies_for_kids
- @movies = Movie.where('rating in ?', %w(G PG))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement