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
This commit is contained in:
Pfingstfrosch
2020-06-05 00:35:04 +02:00
parent 1e87036094
commit ca38d7260d
12 changed files with 38 additions and 36 deletions
@@ -36,9 +36,9 @@ class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
@project = TissCrawler.get_project_details(params)
# create stores the object to the db after creation
favorite_hash = {id: params[:id],
favorite_hash = {id: [params[:id], current_user.id],
# the user who is currently active
user_id: current_user.id,
# user_id: current_user.id,
title: @project['titleDe']}
if FavoriteProject.create(favorite_hash).valid?
FavoriteProject.create(favorite_hash)
@@ -36,9 +36,9 @@ class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
@thesis = TissCrawler.get_thesis_details(params)
# create stores the object to the db after creation
favorite_hash = {id: params[:id],
favorite_hash = {id: [params[:id], current_user.id],
# the user who is currently active
user_id: current_user.id,
# user_id: current_user.id,
title: @thesis['title']['de']}
if FavoriteThesis.create(favorite_hash).valid?
FavoriteThesis.create(favorite_hash)