mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
15 lines
306 B
Ruby
15 lines
306 B
Ruby
class Beer < ApplicationRecord
|
|
include RatingAverage
|
|
|
|
belongs_to :brewery
|
|
has_many :ratings, dependent: :destroy
|
|
has_many :users, through: :ratings
|
|
|
|
validates :name, presence: true
|
|
validates :style_id, presence: true
|
|
|
|
def to_s
|
|
"#{name}, #{(Brewery.find_by_id brewery_id).name}"
|
|
end
|
|
end
|