title: ruby on rails app tutorial can't display micropost page
body: <p>Hi I'm following a rails tutorial and i've kind of veered off the tutorial to do some different things...&amp; i hit a snag.  So the tutorial (michael hartl's) creates a feed of microposts, but it doesn't give each micropost its own page.  This is what i'm trying to do and can't seem to get it working.</p>
  
  <p>So in the feed view which i'm calling "activity" i've got:</p>
  
  <pre><code>&lt;li id="&lt;%= activity_item.id %&gt;"&gt;
    &lt;%= link_to gravatar_for(activity_item.user, :size =&gt; 200), activity_item.user %&gt;&lt;br clear="all"&gt;
    &lt;span class="title"&gt;&lt;%= link_to activity_item.title, @micropost %&gt;&lt;/span&gt;&lt;br clear="all"&gt;
    &lt;span class="user"&gt;
    Joined by &lt;%= link_to activity_item.user.name, activity_item.user %&gt;
    &lt;/span&gt;&lt;br clear="all"&gt;
    &lt;span class="timestamp"&gt;
   &lt;%= time_ago_in_words(activity_item.created_at) %&gt; ago.
   &lt;/span&gt;
   &lt;% if current_user?(activity_item.user) %&gt;
   &lt;%= link_to "delete", activity_item, :method =&gt; :delete,
                                       :confirm =&gt; "Are you sure?",
                                       :title =&gt; activity_item.content %&gt;
   &lt;% end %&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>And when i click on the actual micropost "title" i get the following error saying i've got "No route matches [GET] "/microposts".  I'm sure this is probably an easy fix i'm missing, but I'm a beginner &amp; I've been goin too long &amp; my brain is fried.  </p>
  
  <p>What i basically need to have happen is when i click on the title of a micropost from my activity feed...I need it to go to the unique #show page of that micropost id.  </p>
  
  <p>Here are the models / controllers i believe are relevant.  If i need to post anything else just let me know.  I appreciate any and all help!  Thanks!</p>
  
  <p>static_pages_controller (the home page is where my activity feed shows up</p>
  
  <pre><code>class StaticPagesController &lt; ApplicationController
  
    def home
      if signed_in?
       @micropost = current_user.microposts.build
  
       @activity_items = current_user.activity.paginate(:page =&gt; params[:page])
       @friendactivity_items = current_user.friendactivity.paginate(:page =&gt; params[:page])
      end
    end
  
    def help
    end
  
    def about
    end
  
    def contact
    end
  end
  </code></pre>
  
  <p>Microposts Controller</p>
  
  <pre><code>class MicropostsController &lt; ApplicationController
    before_filter :signed_in_user, :only =&gt; [:create, :destroy]
    before_filter :correct_user,   :only =&gt; :destroy
  
    def index
    end
  
    def new
     @micropost = current_user.microposts.build if signed_in?
    end
  
    def create
      @micropost = current_user.microposts.build(params[:micropost])
     if @micropost.save
      flash[:success] = "Micropost created!"
      redirect_to root_path
     else
      @activity_items = [ ]
      render 'new'
     end
    end
  
   def show
    @micropost = Micropost.find(params[:id])
    @users = @micropost.users.paginate(:page =&gt; params[:page])
   end
  
   def destroy
    @micropost.destroy
    redirect_to root_path
   end
  
    private
  
    def correct_user
      @micropost = current_user.microposts.find_by_id(params[:id])
      redirect_to root_path if @micropost.nil?
    end
  
  end
  </code></pre>
  
  <p>Micropost Model</p>
  
  <pre><code>class Micropost &lt; ActiveRecord::Base
    attr_accessible :content, :title
    belongs_to :user
  
    validates :title, :presence =&gt; true, :length =&gt; { :maximum =&gt; 100 }
    validates :content, :presence =&gt; true, :length =&gt; { :maximum =&gt; 220 }
    validates :user_id, :presence =&gt; true
  
    default_scope :order =&gt; 'microposts.created_at DESC'
  
    # Returns Microposts from the users that the given user follows
    def self.from_users_followed_by(user)
    followed_user_ids = "SELECT followed_id FROM relationships
                       WHERE follower_id = :user_id"
    where("user_id IN (#{followed_user_ids})",
        :user_id =&gt; user.id)
   end
  
  end
  </code></pre>
  
  <p>I'm also adding now the routes.rb file and micropost model as requested</p>
  
  <p>routes.rb</p>
  
  <pre><code>SampleApp::Application.routes.draw do
   resources :users do
    member do
     get :following, :followers
   end
  end
  
  resources :sessions, :only =&gt; [:new, :create, :destroy]
  resources :microposts, :only  =&gt; [:create, :destroy, :show]
  resources :relationships, :only =&gt; [:create, :destroy]
  
  # home page route
  root :to =&gt; 'static_pages#home'
  
  # signup route
  match '/signup', :to =&gt; 'users#new'
  match '/signin', :to =&gt; 'sessions#new'
  match '/signout', :to =&gt; 'sessions#destroy', :via =&gt; :delete
  
  # static pages routes
  match '/help', :to =&gt; 'static_pages#help'
  match '/about', :to =&gt; 'static_pages#about'
  match '/contact', :to =&gt; 'static_pages#contact'
  
  # create a micropost routes
  match '/createamicropost', :to =&gt; 'microposts#new'
  </code></pre>
  
  <p>microposts Model as requested...Thanks!</p>
  
  <pre><code>class Micropost &lt; ActiveRecord::Base
    attr_accessible :content, :title
    belongs_to :user
  
    validates :title, :presence =&gt; true, :length =&gt; { :maximum =&gt; 100 }
    validates :content, :presence =&gt; true, :length =&gt; { :maximum =&gt; 220 }
    validates :user_id, :presence =&gt; true
  
    default_scope :order =&gt; 'microposts.created_at DESC'
  
    # Returns Microposts from the users that the given user follows
    def self.from_users_followed_by(user)
      followed_user_ids = "SELECT followed_id FROM relationships
                       WHERE follower_id = :user_id"
      where("user_id IN (#{followed_user_ids})",
            :user_id =&gt; user.id)
     end
  
  end
  </code></pre>