From 6b47ce065f18fc3579db17d00d2722e1b6e0a029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Miedes=20Garc=C3=A9s?= Date: Fri, 27 Jan 2017 14:27:28 +0100 Subject: [PATCH] Fix buggy associations --- app/models/comment.rb | 2 -- app/models/debate.rb | 1 - app/models/proposal.rb | 1 - config/api.yml | 6 +++--- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 269dac25d..16bb207d3 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -19,8 +19,6 @@ class Comment < ActiveRecord::Base belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true belongs_to :user, -> { with_hidden } - has_many :votes, -> { for_comments }, foreign_key: 'votable_id' - before_save :calculate_confidence_score scope :for_render, -> { with_hidden.includes(user: :organization) } diff --git a/app/models/debate.rb b/app/models/debate.rb index 56adb4f80..8254bdc10 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -17,7 +17,6 @@ class Debate < ActiveRecord::Base belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :geozone has_many :comments, as: :commentable - has_many :votes, -> { for_debates }, foreign_key: 'votable_id' validates :title, presence: true validates :description, presence: true diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 09741f5f9..c69fe4194 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -19,7 +19,6 @@ class Proposal < ActiveRecord::Base belongs_to :geozone has_many :comments, as: :commentable has_many :proposal_notifications - has_many :votes, -> { for_proposals }, foreign_key: 'votable_id' validates :title, presence: true validates :question, presence: true diff --git a/config/api.yml b/config/api.yml index 669602611..d007202cb 100644 --- a/config/api.yml +++ b/config/api.yml @@ -22,7 +22,7 @@ Debate: geozone: Geozone comments: [Comment] public_author: User - votes: [Vote] + votes_for: [Vote] tags: ["ActsAsTaggableOn::Tag"] Proposal: fields: @@ -45,7 +45,7 @@ Proposal: comments: [Comment] proposal_notifications: [ProposalNotification] public_author: User - votes: [Vote] + votes_for: [Vote] tags: ["ActsAsTaggableOn::Tag"] Comment: fields: @@ -60,7 +60,7 @@ Comment: ancestry: string confidence_score: integer public_author: User - votes: [Vote] + votes_for: [Vote] Geozone: fields: id: integer