title: render nested partial for new form
body: <p>I'm trying to render a _new.html.erb partial from a comments controller inside a posts controller.  </p>
  
  <p>My comments resources is nested in my posts resource</p>
  
  <p>routes.rb</p>
  
  <pre><code>  resources :users, :only =&gt; [:show, :create, :new]
  
    resources :posts do
      resources :comments
      resources :memorybooks
    end
  
    root to: 'static_pages#home'
  
    match '/channel',    to: 'static_pages#channel'
    match 'login', to: 'static_pages#login'
    match '/posts', to: 'posts#new'
    match '/users', to: 'users#new'
  </code></pre>
  
  <p>My _new.html.erb partial in my comments controller:</p>
  
  <pre><code>   &lt;%= form_for([@post, @comment]) do |f| %&gt;
  
        &lt;%= f.label :comment %&gt;
        &lt;%= f.text_field :comment %&gt;
  
        &lt;p&gt;
        &lt;center&gt;
        &lt;%= f.submit "Submit", class: "btn btn-large btn-primary" %&gt;
        &lt;/center&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>My comments controller method:</p>
  
  <pre><code>def create
  @post = Post.find_by_id(params[:id])
  @comment = @post.comments.build(params[:comment])
      if @comment.save
      redirect_to @current_post
  else
      render '/'
  end
  end
  </code></pre>
  
  <p>In my show.html.erb file, when I use the following: </p>
  
  <pre><code>&lt;%= render 'comments/new' %&gt;
  </code></pre>
  
  <p>The _new partial form appears, but when I post, I get the error:</p>
  
  <pre><code>No route matches [POST] "/comments"
  </code></pre>
  
  <p>And if I use the following line in show.html.erb</p>
  
  <pre><code>&lt;%= render new_post_comment %&gt;
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>undefined local variable or method `new_post_comment'
  </code></pre>
  
  <p>Below is my rake routes</p>
  
  <pre><code>               users POST   /users(.:format)                               users#create
              new_user GET    /users/new(.:format)                           users#new
                  user GET    /users/:id(.:format)                           users#show
         post_comments GET    /posts/:post_id/comments(.:format)             comments#index
                       POST   /posts/:post_id/comments(.:format)             comments#create
      new_post_comment GET    /posts/:post_id/comments/new(.:format)         comments#new
     edit_post_comment GET    /posts/:post_id/comments/:id/edit(.:format)    comments#edit
          post_comment GET    /posts/:post_id/comments/:id(.:format)         comments#show
                       PUT    /posts/:post_id/comments/:id(.:format)         comments#update
                       DELETE /posts/:post_id/comments/:id(.:format)         comments#destroy
      post_memorybooks GET    /posts/:post_id/memorybooks(.:format)          memorybooks#index
                       POST   /posts/:post_id/memorybooks(.:format)          memorybooks#create
   new_post_memorybook GET    /posts/:post_id/memorybooks/new(.:format)      memorybooks#new
  edit_post_memorybook GET    /posts/:post_id/memorybooks/:id/edit(.:format) memorybooks#edit
       post_memorybook GET    /posts/:post_id/memorybooks/:id(.:format)      memorybooks#show
                       PUT    /posts/:post_id/memorybooks/:id(.:format)      memorybooks#update
                       DELETE /posts/:post_id/memorybooks/:id(.:format)      memorybooks#destroy
                 posts GET    /posts(.:format)                               posts#index
                       POST   /posts(.:format)                               posts#create
              new_post GET    /posts/new(.:format)                           posts#new
             edit_post GET    /posts/:id/edit(.:format)                      posts#edit
                  post GET    /posts/:id(.:format)                           posts#show
                       PUT    /posts/:id(.:format)                           posts#update
                       DELETE /posts/:id(.:format)                           posts#destroy
                  root        /                                              static_pages#home
               channel        /channel(.:format)                             static_pages#channel
                 login        /login(.:format)                               static_pages#login
                              /posts(.:format)                               posts#new
                              /users(.:format)                               users#new
  </code></pre>
  
  <p>Any help would be appreciated!  Thank you!</p>