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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user