mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
added many to many betweer beers and users
This commit is contained in:
@@ -3,6 +3,7 @@ class Beer < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :brewery
|
belongs_to :brewery
|
||||||
has_many :ratings, dependent: :destroy
|
has_many :ratings, dependent: :destroy
|
||||||
|
has_many :users, through: :ratings
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ class User < ApplicationRecord
|
|||||||
validates :username, uniqueness: true, length: { minimum: 3, maximum: 30 }
|
validates :username, uniqueness: true, length: { minimum: 3, maximum: 30 }
|
||||||
|
|
||||||
has_many :ratings
|
has_many :ratings
|
||||||
|
has_many :beers, through: :ratings
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user