Remove unnecessary foreign_key options
When we specify `belongs_to :author`, ActiveRecord automatically uses `author_id` as the foreign key.
This commit is contained in:
@@ -32,7 +32,7 @@ class Budget
|
||||
translates :description, touch: true
|
||||
include Globalizable
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :heading
|
||||
belongs_to :group
|
||||
belongs_to :budget
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Budget::Investment::ChangeLog < ApplicationRecord
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id", required: false
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", required: false
|
||||
|
||||
validates :old_value, presence: true
|
||||
validates :new_value, presence: true
|
||||
|
||||
@@ -12,7 +12,7 @@ class Budget
|
||||
include Sanitizable
|
||||
|
||||
belongs_to :budget
|
||||
belongs_to :next_phase, class_name: "Budget::Phase", foreign_key: :next_phase_id
|
||||
belongs_to :next_phase, class_name: "Budget::Phase"
|
||||
has_one :prev_phase, class_name: "Budget::Phase", foreign_key: :next_phase_id
|
||||
|
||||
validates_translation :summary, length: { maximum: SUMMARY_MAX_LENGTH }
|
||||
|
||||
@@ -24,7 +24,7 @@ class Debate < ApplicationRecord
|
||||
translates :description, touch: true
|
||||
include Globalizable
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :geozone
|
||||
has_many :comments, as: :commentable
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class DirectMessage < ApplicationRecord
|
||||
belongs_to :sender, class_name: "User", foreign_key: "sender_id"
|
||||
belongs_to :receiver, class_name: "User", foreign_key: "receiver_id"
|
||||
belongs_to :sender, class_name: "User"
|
||||
belongs_to :receiver, class_name: "User"
|
||||
|
||||
validates :title, presence: true
|
||||
validates :body, presence: true
|
||||
|
||||
@@ -6,7 +6,7 @@ class Legislation::Annotation < ApplicationRecord
|
||||
serialize :ranges, Array
|
||||
|
||||
belongs_to :draft_version, class_name: "Legislation::DraftVersion", foreign_key: "legislation_draft_version_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
has_many :comments, as: :commentable, dependent: :destroy
|
||||
|
||||
validates :text, presence: true
|
||||
|
||||
@@ -20,7 +20,7 @@ class Legislation::PeopleProposal < ApplicationRecord
|
||||
acts_as_paranoid column: :hidden_at
|
||||
|
||||
belongs_to :process, class_name: "Legislation::Process", foreign_key: "legislation_process_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
has_many :comments, as: :commentable
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
@@ -20,7 +20,7 @@ class Legislation::Proposal < ApplicationRecord
|
||||
acts_as_paranoid column: :hidden_at
|
||||
|
||||
belongs_to :process, class_name: "Legislation::Process", foreign_key: "legislation_process_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :geozone
|
||||
has_many :comments, as: :commentable
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class Legislation::Question < ApplicationRecord
|
||||
translates :title, touch: true
|
||||
include Globalizable
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :process, class_name: "Legislation::Process", foreign_key: "legislation_process_id"
|
||||
|
||||
has_many :question_options, -> { order(:id) }, class_name: "Legislation::QuestionOption", foreign_key: "legislation_question_id",
|
||||
|
||||
@@ -28,7 +28,7 @@ class Poll < ApplicationRecord
|
||||
has_many :ballot_sheets
|
||||
|
||||
has_and_belongs_to_many :geozones
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :related, polymorphic: true
|
||||
belongs_to :budget
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Poll::Answer < ApplicationRecord
|
||||
belongs_to :question, -> { with_hidden }
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
|
||||
delegate :poll, :poll_id, to: :question
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Poll::PairAnswer < ApplicationRecord
|
||||
belongs_to :question, -> { with_hidden }
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :answer_right, class_name: "Poll::Question::Answer", foreign_key: "answer_rigth_id"
|
||||
belongs_to :answer_left, class_name: "Poll::Question::Answer", foreign_key: "answer_left_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :answer_right, class_name: "Poll::Question::Answer"
|
||||
belongs_to :answer_left, class_name: "Poll::Question::Answer"
|
||||
|
||||
delegate :poll, :poll_id, to: :question
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ class Poll::PartialResult < ApplicationRecord
|
||||
VALID_ORIGINS = %w[web booth]
|
||||
|
||||
belongs_to :question, -> { with_hidden }
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :booth_assignment
|
||||
belongs_to :officer_assignment
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Poll::Question < ApplicationRecord
|
||||
include Globalizable
|
||||
|
||||
belongs_to :poll
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
|
||||
has_many :comments, as: :commentable
|
||||
has_many :answers, class_name: "Poll::Answer"
|
||||
|
||||
@@ -9,7 +9,7 @@ class Poll::Question::Answer < ApplicationRecord
|
||||
|
||||
accepts_nested_attributes_for :documents, allow_destroy: true
|
||||
|
||||
belongs_to :question, class_name: "Poll::Question", foreign_key: "question_id"
|
||||
belongs_to :question, class_name: "Poll::Question"
|
||||
has_many :videos, class_name: "Poll::Question::Answer::Video"
|
||||
|
||||
validates_translation :title, presence: true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Poll::Question::Answer::Video < ApplicationRecord
|
||||
belongs_to :answer, class_name: "Poll::Question::Answer", foreign_key: "answer_id"
|
||||
belongs_to :answer, class_name: "Poll::Question::Answer"
|
||||
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Poll::Recount < ApplicationRecord
|
||||
VALID_ORIGINS = %w[web booth letter].freeze
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :booth_assignment
|
||||
belongs_to :officer_assignment
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Proposal < ApplicationRecord
|
||||
include Globalizable
|
||||
translation_class_delegate :retired_at
|
||||
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
belongs_to :geozone
|
||||
has_many :comments, as: :commentable, dependent: :destroy
|
||||
has_many :proposal_notifications, dependent: :destroy
|
||||
|
||||
@@ -2,7 +2,7 @@ class ProposalNotification < ApplicationRecord
|
||||
include Graphqlable
|
||||
include Notifiable
|
||||
|
||||
belongs_to :author, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, class_name: "User"
|
||||
belongs_to :proposal
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
@@ -5,7 +5,7 @@ class RelatedContent < ApplicationRecord
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
belongs_to :author, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, class_name: "User"
|
||||
belongs_to :parent_relationable, polymorphic: true, touch: true
|
||||
belongs_to :child_relationable, polymorphic: true, touch: true
|
||||
has_one :opposite_related_content, class_name: "RelatedContent", foreign_key: :related_content_id
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class SignatureSheet < ApplicationRecord
|
||||
belongs_to :signable, polymorphic: true
|
||||
belongs_to :author, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, class_name: "User"
|
||||
|
||||
VALID_SIGNABLES = %w[Proposal Budget::Investment]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class Topic < ApplicationRecord
|
||||
include Notifiable
|
||||
|
||||
belongs_to :community
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
|
||||
has_many :comments, as: :commentable
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class VotationSetAnswer < ApplicationRecord
|
||||
belongs_to :votation_type
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id"
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User"
|
||||
|
||||
scope :by_author, -> (author) { where(author: author) }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user