title: Rails match user_id column in table A to user_id column in table B then use table B data
body: <p>I have an articles table in my Rails project for making news articles. In that table I have a user_id column which populates the column with the current_user id. I then have a Drivers table which has the same name field user_id.</p>
  <p>What I want to do is create a variable called @author and then use the data in the Drivers table (like name, profile pic etc)</p>
  <p><em>The error i'm getting now is &quot;undefined method `profile_pic' for #Article::ActiveRecord_Relation:0x00007fac792a7678&quot;</em></p>
  <p>My article model is this:</p>
  <pre><code>class Article &lt; ApplicationRecord
    has_one :drivers
    #has_many :comments
  end
  </code></pre>
  <p>My drivers model is:</p>
  <pre><code>class Driver &lt; ApplicationRecord
    has_many :articles
  end
  </code></pre>
  <p>and finally in my articles_controller i've tried to match both fields:</p>
  <pre><code>def show
     @article = Article.find(params[:id])
     @driver = Article.where(user_id: Driver.pluck(:user_id))
  end
  </code></pre>
  <p>Any direction is appreciated. Thanks</p>