Fix buggy associations
This commit is contained in:
@@ -19,8 +19,6 @@ class Comment < ActiveRecord::Base
|
|||||||
belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true
|
belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true
|
||||||
belongs_to :user, -> { with_hidden }
|
belongs_to :user, -> { with_hidden }
|
||||||
|
|
||||||
has_many :votes, -> { for_comments }, foreign_key: 'votable_id'
|
|
||||||
|
|
||||||
before_save :calculate_confidence_score
|
before_save :calculate_confidence_score
|
||||||
|
|
||||||
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class Debate < ActiveRecord::Base
|
|||||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||||
belongs_to :geozone
|
belongs_to :geozone
|
||||||
has_many :comments, as: :commentable
|
has_many :comments, as: :commentable
|
||||||
has_many :votes, -> { for_debates }, foreign_key: 'votable_id'
|
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Proposal < ActiveRecord::Base
|
|||||||
belongs_to :geozone
|
belongs_to :geozone
|
||||||
has_many :comments, as: :commentable
|
has_many :comments, as: :commentable
|
||||||
has_many :proposal_notifications
|
has_many :proposal_notifications
|
||||||
has_many :votes, -> { for_proposals }, foreign_key: 'votable_id'
|
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :question, presence: true
|
validates :question, presence: true
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Debate:
|
|||||||
geozone: Geozone
|
geozone: Geozone
|
||||||
comments: [Comment]
|
comments: [Comment]
|
||||||
public_author: User
|
public_author: User
|
||||||
votes: [Vote]
|
votes_for: [Vote]
|
||||||
tags: ["ActsAsTaggableOn::Tag"]
|
tags: ["ActsAsTaggableOn::Tag"]
|
||||||
Proposal:
|
Proposal:
|
||||||
fields:
|
fields:
|
||||||
@@ -45,7 +45,7 @@ Proposal:
|
|||||||
comments: [Comment]
|
comments: [Comment]
|
||||||
proposal_notifications: [ProposalNotification]
|
proposal_notifications: [ProposalNotification]
|
||||||
public_author: User
|
public_author: User
|
||||||
votes: [Vote]
|
votes_for: [Vote]
|
||||||
tags: ["ActsAsTaggableOn::Tag"]
|
tags: ["ActsAsTaggableOn::Tag"]
|
||||||
Comment:
|
Comment:
|
||||||
fields:
|
fields:
|
||||||
@@ -60,7 +60,7 @@ Comment:
|
|||||||
ancestry: string
|
ancestry: string
|
||||||
confidence_score: integer
|
confidence_score: integer
|
||||||
public_author: User
|
public_author: User
|
||||||
votes: [Vote]
|
votes_for: [Vote]
|
||||||
Geozone:
|
Geozone:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
|
|||||||
Reference in New Issue
Block a user