title: Adding records to activerecord array changes attribute value
body: <p>I have a user model that has many completed tasks. Also I have user to user relationship for subscribing, following etc. actions. I am trying to render all user completed tasks, and completed tasks for users that the user are following. The problem is, when i'm adding the followed users completed tasks to the users completed task array, the user_id column is changed from the followed users id to the user id. This is pretty weird and don't have any idea what is causing this. Sorry if I couldn't explain it clearly.</p>
  
  <p>Here's the codes:</p>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    include BCrypt
  
    before_create :generate_auth_token!
  
    has_secure_password :validations =&gt; false
  
    has_many :completed_tasks, dependent: :destroy
  
    has_many :relationships, foreign_key: "follower_id",
                             class_name: "Relationship",
                             dependent: :destroy
    has_many :followed_users, through: :relationships, :source =&gt; "followed"
  
    has_many :reverse_relationships, foreign_key: "followed_id",
                                     class_name:  "Relationship",
                                     dependent:   :destroy
    has_many :followers, through: :reverse_relationships
  
    def generate_auth_token!
      begin
        self.auth_token = SecureRandom.hex
      end while self.class.exists?(auth_token: auth_token)
    end
  end
  </code></pre>
  
  <p>completed_task.rb</p>
  
  <pre><code>class CompletedTask &lt; ActiveRecord::Base
    belongs_to :user
    validates :user_id, :presence =&gt; true
  end
  </code></pre>
  
  <p>completed_tasks_controller.rb Here in the @user.completed_tasks &lt;&lt; user.completed_tasks the user_id values gets changed to @user.id</p>
  
  <pre><code>def index
    if valid_auth_token?
      @completed_tasks = @user.completed_tasks
      @user.followed_users.each do |user|
        @completed_tasks &lt;&lt; user.completed_tasks
      end
      render file: "api/v1/completed_tasks/index.json.jbuilder", status: :ok
    else
      head :unauthorized
    end
  end
  </code></pre>