title: Undefined method 'title' for nil:NilClass
body: <p>I am following railsspace book but when i trying edit show and eliminate a post owner (chapter 15) I get: error message</p>
  
  <pre><code>undefined method `title' for nil:NilClass
  </code></pre>
  
  <p>follow extact:</p>
  
  <pre><code>1: &lt;div class="post"&gt;
  2: &lt;div class="post_title"&gt;
  3:  
  4: &lt;%= sanitize post.title %&gt;
  5: &lt;% unless hide_edit_links? %&gt;
  6: &lt;span style="float:right"&gt;
  7: &lt;%= link_to_unless_current 'Mostrar', blog_post_path(post.blog, post) %&gt; |
  </code></pre>
  
  <p>Ruby 1.9.2 
  Rails 3.1.3</p>
  
  <p>The controller, views and routes is as follow:</p>
  
  <p>Controller: posts_controller</p>
  
  <pre><code>  # Encoding: UTF-8
  class PostsController &lt; ApplicationController
    helper :profile
    before_filter :protect, :protect_blog
    # GET /posts
    # GET /posts.xml
    def index
      #Recheck implement paginate for Rails 3.1.3
      #@pages, @posts = paginate(@blog.posts)
      @posts = @blog.posts
      @title = "Administración del Blog"
      respond_to do |format|
        format.html # index.rhtml
        format.xml { render :xml =&gt; @posts.to_xml }
      end
    end
  
    # GET /posts/1
    # GET /posts/1.xml
    def show
      @post = Post.find(params[:id])
      @title = @post.title
      respond_to do |format|
        format.html # show.rhtml
        format.xml { render :xml =&gt; @post.to_xml }
      end
    end
  
    # GET /posts/new
    def new
      @post = Post.new
      @title = "Nuevo post"
    end
  
    # GET /posts/1;edit
    def edit
      @post = Post.find(params[:id])
      @title = "Edit #{@post.title}"
    end
  
    # POST /posts
    # POST /posts.xml
    def create
      @post = Post.new(params[:post])
      @post.blog = @blog
  
      respond_to do |format|
        if @post.duplicate? or @blog.posts &lt;&lt; @post
          flash[:notice] = 'Post was successfully created.'
          format.html { redirect_to blog_post_url(:id =&gt; @post) }
          format.xml  { head :created, :location =&gt; blog_post_url(:id =&gt; @post) }
        else
          format.html { render :action =&gt; "new" }
          format.xml { render :xml =&gt; @post.errors.to_xml }
        end
      end
    end
  
    # PUT /posts/1
    # PUT /posts/1.xml
    def update
      @post = Post.find(params[:id])
      respond_to do |format|
        if @post.update_attributes(params[:post])
          flash[:notice] = 'Post was successfully updated.'
          format.html { redirect_to post_url(:id =&gt; @post) }
          format.xml { head :ok }
        else
          format.html { render :action =&gt; "edit" }
          format.xml { render :xml =&gt; @post.errors.to_xml }
        end
      end
    end
  
    # DELETE /posts/1
    # DELETE /posts/1.xml
    def destroy
      @post = Post.find(params[:id])
      @post.destroy
      respond_to do |format|
        format.html { redirect_to posts_url }
        format.xml { head :ok }
      end
    end
  
    private
  
    # Ensure that user is blog owner, and create @blog.
    def protect_blog
      @blog = Blog.find(params[:blog_id])
      user = User.find(session[:user_id])
      unless @blog.user == user
        flash[:notice] = "That isn't your blog!"
        redirect_to hub_url
      return false
      end
    end
  end
  </code></pre>
  
  <p>View: index</p>
  
  <pre><code>&lt;h2&gt;Sus Blog Posts&lt;/h2&gt;
  &lt;p class="edit_link"&gt;
  &lt;%= link_to 'Agregar nuevo post', new_blog_post_path %&gt;
  &lt;%= "| Pages: #{pagination_links(@pages)}" if paginated? %&gt;
  &lt;/p&gt;
  &lt;%= render :partial =&gt; "post", :collection =&gt; @posts %&gt;
  </code></pre>
  
  <p>View: post</p>
  
  <pre><code>&lt;div class="post"&gt;
  &lt;div class="post_title"&gt;
  
  &lt;%= sanitize post.title %&gt;
  &lt;% unless hide_edit_links? %&gt;
  &lt;span style="float:right"&gt;
  &lt;%= link_to_unless_current 'Mostrar', blog_post_path(post.blog, post) %&gt; |
  &lt;%= link_to_unless_current 'Editar', edit_blog_post_path(post.blog, post) %&gt; |
  &lt;%= link_to 'Eliminar', blog_post_path(post.blog, post),
  :confirm =&gt; 'Deseas eliminar este post?', :method =&gt; :delete %&gt;
  &lt;/span&gt;
  &lt;% end %&gt;
  &lt;/div&gt;
  &lt;div class="post_body"&gt;&lt;%= sanitize post.body %&gt;&lt;/div&gt;
  &lt;div class="post_creation_date"&gt;
  Publicado &lt;%= time_ago_in_words post.created_at %&gt; ago
  &lt;% if post.updated_at != post.created_at %&gt;
  &lt;br /&gt; Modified &lt;%= time_ago_in_words post.updated_at %&gt; ago
  &lt;% end %&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In this view , i has triying put @ in the variable post =@post, but it not work
  Routes</p>
  
  <pre><code>Expression::Application.routes.draw do
  
    get "email/remind"
  
    get "avatar/index"
  
    get "avatar/upload"
  
    get "avatar/delete"
  
    get "community/index"
  
    get "community/browse"
  
    get "community/search"
  
    get "faq/index"
  
    get "faq/edit"
  
    get "spec/index"
  
    get "spec/edit"
  
    get "profile/index"
  
    get "profile/show"
  
    get "user/index"
  
    get "user/register"
  
    get "site/index"
  
    get "site/about"
  
    get "site/help"
  
    get "user/login"
  
    get "user/logout"
  
    get "user/edit"
  
    get "user_mailer/welcome_email"
  
    post "user/register"
  
    post "user/login"
  
    post "user/edit"
  
    post "spec/edit"
  
    post "faq/edit"
  
    post "community/index"
  
    post "community/search"
  
    post "avatar/upload"
  
    post "email/remind"
  
    resources :blogs do
      resources :posts
    end
  
    # The priority is based upon order of creation:
    # first created -&gt; highest priority.
  
    # Sample of regular route:
    #   match 'products/:id' =&gt; 'catalog#view'
    # Keep in mind you can assign values other than :controller and :action
  
    # Sample of named route:
    #   match 'products/:id/purchase' =&gt; 'catalog#purchase', :as =&gt; :purchase
    # This route can be invoked with purchase_url(:id =&gt; product.id)
  
    # Sample resource route (maps HTTP verbs to controller actions automatically):
    #   resources :products
  
    # Sample resource route with options:
    #   resources :products do
    #     member do
    #       get 'short'
    #       post 'toggle'
    #     end
    #
    #     collection do
    #       get 'sold'
    #     end
    #   end
  
    # Sample resource route with sub-resources:
    #   resources :products do
    #     resources :comments, :sales
    #     resource :seller
    #   end
  
    # Sample resource route with more complex sub-resources
    #   resources :products do
    #     resources :comments
    #     resources :sales do
    #       get 'recent', :on =&gt; :collection
    #     end
    #   end
  
    # Sample resource route within a namespace:
    #   namespace :admin do
    #     # Directs /admin/products/* to Admin::ProductsController
    #     # (app/controllers/admin/products_controller.rb)
    #     resources :products
    #   end
  
    # You can have the root of your site routed with "root"
    # just remember to delete public/index.html.
    # root :to =&gt; 'welcome#index'
  
    root :to =&gt; 'site#index'
  
    # match'', :controller =&gt; 'site', :action =&gt; 'index', :id =&gt; nil
    resources :user
    match '/register', :to =&gt; 'user#register'
    match '/about', :to =&gt; 'user#about'
    match '/help', :to =&gt; 'user#help'
    match '/login', :to =&gt;'user#login'
    match '/edit', :to =&gt;'user#edit'
    match '/user/welcome_email', :to =&gt; 'user#create'
  
    #resources :profile
    #match '/show', :to =&gt; 'profile#show'
  
    # Install the default route as the lowest priority.
    match ':controller/:action/:id'
    match 'profile',  :to =&gt; 'profile#show', :as =&gt; "profile"
    match 'hub', :to =&gt; 'user#index', :as =&gt; 'hub'
  
    ##Change Route pagina 343
    # You can have the root of your site routed by hooking up ''
    # -- just remember to delete public/index.html.
    match '', :controller =&gt; 'site', :action =&gt; 'index', :id =&gt; nil
  ###
  
  #match'', :controller =&gt; 'user', :action =&gt; 'about', :id =&gt; nil
  #match'', :controller =&gt; 'user', :action =&gt; 'help', :id =&gt; nil
  
  # See how all your routes lay out with "rake routes"
  
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
  end
  </code></pre>
  
  <p>ApplicationStacktrace</p>
  
  <pre><code>app/views/posts/_post.erb:4:in `_app_views_posts__post_erb__1793130860277527745_40556500'
  app/views/posts/show.html.erb:3:in `_app_views_posts_show_html_erb__2356198700875868089_40643800'
  app/controllers/posts_controller.rb:23:in `show
  </code></pre>