added many to many betweer beers and users

This commit is contained in:
Aaro Koivukangas
2023-08-10 18:33:51 +03:00
parent 77ede55a52
commit babe5573b1
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -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
+1
View File
@@ -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