title: i only want to display posts created by user in index page in my rails app instead of all posts
body: <p>This is my posts controller:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
      before_action :authenticate_user!
  
      def index
          @post = Post.all
      end
  
      def new
          @post = Post.new
      end
  
      def create
          @post = Post.new(set_post)
          @post.user_id = current_user.id
  
          if @post.save
              redirect_to post_path(@post)
          else
              redirect_to new_post_path
          end
      end
  </code></pre>
  
  <p>My models:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
      has_attached_file :image, styles: { medium: "400x400#" }
      validates_attachment_content_type :image, content_type: /\Aimage 
         \/.*\Z/
      belongs_to :user
  end
  
  class User &lt; ActiveRecord::Base
      devise :database_authenticatable, :registerable,
       :recoverable, :rememberable, :trackable, :validatable
      has_many :posts
  end
  </code></pre>
  
  <p>Now what I have to do is in my index action where there are all posts I need only the post of user who created it, so when user gets logged in he 
  should be redirected to his own posts instead of all posts. I am new to rails, any suggestion would be appreciated. I don't know what to put in index and what to add in views. I have used Devise   </p>