Last active
June 27, 2019 21:08
-
-
Save jasterix/fae878b10c5cdd1835e2682d61f2eb2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Show < ActiveRecord::Base | |
def self.highest_rating | |
Show.maximum(:rating) | |
end | |
def self.most_popular_show | |
self.where("rating=?",self.highest_rating).first | |
end | |
def self.lowest_rating | |
Show.minimum(:rating) | |
end | |
def self.least_popular_show | |
self.where("rating = ?", self.lowest_rating).last | |
end | |
def self.ratings_sum | |
Show.sum("rating") | |
end | |
def self.popular_shows | |
self.where("rating > ?", 5) | |
end | |
def self.shows_by_alphabetical_order | |
self.order(:name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment