title: link_to post ID in Rails
body: <p>In my feed I have this:</p>
  
  <pre><code>&lt;span class="title"&gt;&lt;strong&gt;&lt;%= link_to feed_item.title, @micropost %&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;
  </code></pre>
  
  <p>I cannot figure out how to make it link to the individual pages for posts.</p>
  
  <p>Right now it links to: <code>http://localhost:3000/microposts</code> and I get an error: <strong>No route matches [GET] "/microposts"</strong></p>
  
  <p>if I manually type the URL: <code>http://localhost:3000/microposts/25</code> I can see the indivual page for the post.</p>
  
  <p>This works fin linking to a user profile, but I can't get the link working to a micropost's page.
  &lt;%= link_to feed_item.user.name, feed_item.user %><br></p>
  
  <p>I'm new to rails and I'm trying to figure this out. Any help would be appreciated.</p>
  
  <p>microposts_controller.rb</p>
  
  <pre><code>class MicropostsController &lt; ApplicationController
    before_filter :signed_in_user, only: [:create, :destroy]
    before_filter :correct_user,   only: :destroy
  
    def index
    end
  
    def show
      @micropost = Micropost.find(params[:id])
    end
  
    def create
      @micropost = current_user.microposts.build(params[:micropost])
      if @micropost.save
        flash[:success] = "Micropost created!"
        redirect_to root_url
      else
        @feed_items = []
        render 'static_pages/home'
      end
    end
  
    def destroy
      @micropost.destroy
      redirect_to root_url
    end
  
    private
  
    def correct_user
      @micropost = current_user.microposts.find_by_id(params[:id])
      redirect_to root_url if @micropost.nil?
    end
  end
  </code></pre>
  
  <p>config/routes.rb</p>
  
  <pre><code>SampleApp::Application.routes.draw do
    resources :users do
      member do
        get :following, :followers
      end
    end
    resources :sessions, only: [:new, :create, :destroy]
    resources :microposts, only: [:create, :destroy, :show]
    resources :relationships, only: [:create, :destroy]
  
    root to: 'static_pages#home'
  
    match '/signup',  to: 'users#new'
    match '/signin',  to: 'sessions#new'
    match '/signout', to: 'sessions#destroy', via: :delete
  
    match '/help',    to: 'static_pages#help'
    match '/about',   to: 'static_pages#about'
    match '/contact', to: 'static_pages#contact'
  end
  </code></pre>
  
  <p>_feed_item.html.erb</p>
  
  <pre><code>&lt;li id="&lt;%= feed_item.id %&gt;"&gt;
    &lt;%= link_to gravatar_for(feed_item.user), feed_item.user %&gt;
    &lt;span class="title"&gt;&lt;strong&gt;&lt;%= link_to feed_item.title, micropost_path(@micropost) %&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;
      &lt;span class="user"&gt;
        &lt;p&gt;&lt;small&gt;Created by: &lt;%= link_to feed_item.user.name, feed_item.user %&gt;&lt;br&gt;
          &lt;%= feed_item.loc1T %&gt;&lt;br&gt;
           &lt;%= feed_item.startTime.strftime('%A, %B %d, %Y') %&gt;&lt;/small&gt;&lt;/p&gt;
      &lt;/span&gt;
      &lt;span class="content"&gt;&lt;%= feed_item.content %&gt;&lt;/span&gt;
      &lt;span class="timestamp"&gt;
        Posted &lt;%= time_ago_in_words(feed_item.created_at) %&gt; ago.
      &lt;/span&gt;
    &lt;% if current_user?(feed_item.user) %&gt;
      &lt;%= link_to "delete", feed_item, method: :delete,
                                       data: { confirm: "Are you sure?" },
                                       title: feed_item.content %&gt;
    &lt;% end %&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>feed.html.erb</p>
  
  <pre><code>&lt;% if @feed_items.any? %&gt;
    &lt;ol class="microposts"&gt;
      &lt;%= render partial: 'shared/feed_item', collection: @feed_items %&gt;
    &lt;/ol&gt;
    &lt;%= will_paginate @feed_items %&gt;
  &lt;% end %&gt;`
  </code></pre>
  
  <p>static_pages_controller</p>
  
  <pre><code>class StaticPagesController &lt; ApplicationController
    def home
      if signed_in?
        @micropost  = current_user.microposts.build
        @feed_items = current_user.feed.paginate(page: params[:page])
      end
    end
  
    def help
    end
  
    def about
    end
  
    def contact
    end
  end
  </code></pre>