title: Rails query database and store into variable in controller
body: <p>I've been reading through documentation in the rails guides and I cant seem to find an answer on how to do this.</p>
  
  <p>I want to be able to query a specific column in my model and store it into a variable. i think the best thing I can do is write the SQL query to explain it. </p>
  
  <p>Here's my controller definition</p>
  
  <pre><code>  def upvote
      @request = Request.find(params[:request_id]) # Do you still need this ?
  
  
      @requestID = Request.find(params[:id])
      @requestEmail = Request.where(id: @requestID).select(:email)
  
  
      @request.email = current_user.email
      @requestNewEmail = @request.email + ', ' +  @requestEmail
      @request.email = @requestNewEmail
  
      @request.increment!(:voteCount)
      @request.save
      render json: { voteCount: @request.voteCount , email: @request.email}
    end 
  </code></pre>
  
  <p>Here's what I'd like to accomplish:</p>
  
  <pre><code>SELECT email FROM requests WHERE id = requestID
  </code></pre>
  
  <p>Everything I've tried either returns the error <code>Couldn't find Request without an ID</code></p>
  
  <p>Or <code>no implicit conversion from Request to string</code></p>
  
  <p>What am I missing?</p>