mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
15 lines
365 B
Ruby
15 lines
365 B
Ruby
class Rating < ApplicationRecord
|
|
belongs_to :beer
|
|
belongs_to :user
|
|
|
|
validates :score, numericality: { greater_than_or_equal_to: 1,
|
|
less_than_or_equal_to: 50,
|
|
only_integer: true }
|
|
|
|
scope :recent, -> { Rating.order(created_at: :desc) }
|
|
|
|
def to_s
|
|
"#{beer.name}: #{score}"
|
|
end
|
|
end
|