title: Ruby On Rails ActiveRecord select stuff with WHERE condition
body: <p>I have <code>Post</code> and <code>User</code> entities in my application.</p>
  
  <p>They have <code>belongs_to</code> and <code>has_many</code> relationships accordingly. I use <code>gem devise</code> as user authorization/authentication system.</p>
  
  <p>This piece of code selects all posts if <code>Post</code> has <code>user_id</code> and it's the same as <code>current_user.id</code>, and assigns it to the instance variable:</p>
  
  <pre><code>@post = Post.where(:user_id =&gt; current_user.id)
  </code></pre>
  
  <p>Question is:</p>
  
  <p><strong>How could I select latest post created by user (I think I'd use <code>.last</code> method to achieve that)</strong></p>
  
  <p>But the problem is that I don't know how to use <code>.where</code> and <code>.last</code> in one query inside of my instance variable.</p>