title: Having 2 foreign keys from one table in the same table rails
body: <p>I am trying to implement comment replying feature to my project, however i am not very sure with the method i m using. My basic idea is to keep all the comments in one table, while having another table <strong>comments_replies</strong> which will have the parent comment(comment) and the comment(reply). now i have something like this is migrations of <strong>comments_replies</strong>:</p>
  
  <pre><code>create_table :comments_replies do |t|
    t.integer :parent_comment_id, index: true, foreign_key_column_for: :comments, null: false
    t.integer :reply_comment_id, index: true, foreign_key_column_for: :comments, null: false
    t.timestamps null: false
  end
  </code></pre>
  
  <p>and in model comments_reply.rb</p>
  
  <pre><code>belongs_to :comment, class_name: 'Comment'
  </code></pre>
  
  <p>and in model comment.rb</p>
  
  <pre><code>has_many :comments_replies, foreign_key: :parent_comment_id, foreign_key: :reply_comment_id
  </code></pre>
  
  <p>as for the second part since i m trying to use RSPEC for testing purposes, in model comments_reply_spec.rb i have:</p>
  
  <pre><code>require 'rails_helper'
  
  RSpec.describe CommentsReply, type: :model do
    let(:comments_reply) { create(:comments_reply) }
    subject { comments_reply }
  
    it { is_expected.to respond_to(:parent_comment_id) }
    it { is_expected.to respond_to(:reply_comment_id) }
  end
  </code></pre>
  
  <p>but i am not sure how to test this case properly, so any suggestions would be appreciated</p>