title: How to get posts with few conditions rails
body: <p>Users can add posts, Posts are categorized<br>
  When I'm  in user's profile I can see only his posts</p>
  
  <p>I want to see this user's posts from chosen category, how to do this?
  How to view posts of this user from chosen category?</p>
  
  <p>This is link to category</p>
  
  <pre><code>link_to category.name, posts_path(category: category.name, user_id: current_user), class:"category"
  </code></pre>
  
  <p>below is my method</p>
  
  <pre><code>def my_things   
      if params[:category].blank?
          @posts = Post.where(user_id: current_user).order("created_at DESC")
      else
          @category_id = Category.find_by(name: params[:category]).id
          @posts = Post.where(category_id: @category_id).order('created_at DESC')
      end 
  end
  </code></pre>
  
  <p></p>