tiss2go/app/models/favorite_course.rb
Pfingstfrosch ca38d7260d fixed bugfix where another user could not store the same object again
fixed the primary keys => all the classes have now composite primary key which contais an id + user_id, necessary gem: 'composite_primary_keys'
fixed the user_id relation => every class now "belongs_to" user

pls kill me know
2020-06-05 00:35:04 +02:00

7 lines
221 B
Ruby

class FavoriteCourse < ApplicationRecord
self.primary_keys = :id, :user_id
validates :title, :semester, :number, presence: true
validates :semester, :number, uniqueness: {scope: [:semester, :number, :user_id]}
end