title: How to fix rails Couldn't find Post without an ID Error
body: <p>I am new to rails and little know of ruby, I have just stared tutorial from Rails Guide 4.0. Everything was going fine just stuck on one Error : Couldn't find Post without an ID.</p>
  
  <p>I did everything as in Rails Guide Getting Started Of Rails.</p>
  
  <p>Here is code from rails guide : </p>
  
  <pre><code>def show
    @posts = Post.find(params[:id])
  end
  </code></pre>
  
  <p>and Here is View Code : </p>
  
  <pre><code>&lt;p&gt;
    &lt;strong&gt;Title:&lt;/strong&gt;
    &lt;%= @posts.title %&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Text:&lt;/strong&gt;
    &lt;%= @posts.text %&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>After this code rails guide tell you should finally be able to create new posts. Visit localhost:3000/posts/new and give it a try!. But after create new post it showing me error. </p>
  
  <p>I thought it could be issue because i didn't created index action yet so i done with index, After index action when i try to visit this address normally it should display all record from database but rather then display record showing same error : Couldn't find Post without an ID</p>
  
  <p>I tried too many posts on stackoverflow but all related to some other actions that are not useful for me.</p>
  
  <p>Please help me to fix this issue, i am just thinking it shouldn't be because i am following rails guide.</p>
  
  <p>I am following rails getting started guide as it said i added index action and show action. So as in book it said with index action when you visit this address /posts you should see all posts and when you create new post it will redirect to show last post you entered, </p>
  
  <p>I was using redirect_to @post but that comes with error i stuck then i use <code>redirect_to action: :show, id: @post.id</code></p>
  
  <p>it's working when i create a new post then it redirect to /posts?id=last_inserted_id but as i saw other scaffold address should be posts/1 or etc and when i visit /posts it should show all the posts action defined as index in controller.</p>
  
  <pre><code>routes.rb
  
  &lt;code&gt;
    Blog::Application.routes.draw do
    root "welcome#new"
  
    resource :posts
  &lt;/code&gt;
  </code></pre>
  
  <p>Controller :</p>
  
  <pre><code>class PostsController &lt; ApplicationController
  
  
    def index
      @post = Post.all
      respond_to do |format|
        format.html #index.html.erb
      end
    end
  
    def show
      @post = Post.find(params[:id])
      respond_to do |format|
        format.html #show.html.erb
      end
    end
  
    def new
  
    end
  
    def create
      @post = Post.new post_params
      @post.save
      redirect_to action: :show, id: @post.id
    end
  
    private
      def post_params
        params.require(:post).permit(:title, :message)
      end
  end
  </code></pre>
  
  <p>Thanks</p>