title: Passing :new to Rails url_for
body: <p>Maybe I'm stupid but Rails provides this nifty syntax for generating URL's like so:</p>
  
  <pre><code>url_for([user, comment]) # =&gt; /users/1/comment/1
  </code></pre>
  
  <p>Passing <code>:edit</code> allows me to create something like this:</p>
  
  <pre><code>url_for([:edit, user, comment]) # =&gt; /users/1/comment/1/edit
  </code></pre>
  
  <p>but is there some way to do following?</p>
  
  <pre><code>url_for([:new, user, comments]) # =&gt; NoMethodError: undefined method `new_user_comments_url'
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE:</strong> Added more information.</p>
  
  <p>My routes.rb:</p>
  
  <pre><code>resources :users do
    resources :comments
  end
  
  resources :posts do
    resources :comments
  end
  </code></pre>
  
  <p>My problem here is, that I can't use Rails auto-generated url helper (<code>user_comments_url</code>), because I'm sharing the views for both user comments and post comments.</p>
  
  <p>There are two workarounds (but no one feels like the "Rails"-way) for my problem:</p>
  
  <ol>
  <li><p>Adding logic to the view, e.g. some if conditions. </p></li>
  <li><p>Defining my own url helpers like <code>new_parent_comment(user_or_blog)</code>.</p></li>
  </ol>