title: Rails: form_for setting Nested Routes with custom action
body: <p>I have a problem with nested routes with custom action. I want to make a form url path: <code>localhost:3000/requests/2/images/create_for_request</code>. Where the custom action: <code>create_for_request</code> is called in the <code>ImagesController</code>, with the <code>request_id</code> from <code>requests/show.html.erb</code>. 
  Below is the error:</p>
  
  <pre><code>No route matches {:action=&gt;"create_for_request", :controller=&gt;"requests", :id=&gt;"11"}
  </code></pre>
  
  <p>request.rb:</p>
  
  <pre><code>class Request &lt; ApplicationRecord
    belongs_to :user
    alias_attribute :requester, :user
    has_many :requests_has_images
    has_many :response_images, through: :requests_has_images, class_name: 'Image', source: 'image'
    has_many :chosen_images, lambda {where(chosen: true)}, through: :requests_has_images, class_name: 'Image', source: 'image'
  
    def is_requester(user)
      if user &amp;&amp; self.user_id == user.id
        return true
      else
        return false
      end
    end  
  end
  </code></pre>
  
  <p>config.rb</p>
  
  <pre><code>  resources :requests do
      post 'images/create_for_request' =&gt; 'images#create_for_request'
      put 'images/edit_for_request' =&gt; 'images#edit_for_request'
      post 'images/delete_for_request' =&gt; 'images#delete_for_request'
    end
  </code></pre>
  
  <p>requests/show.html.erb:</p>
  
  <pre><code>&lt;h2&gt;Make Response Image&lt;/h2&gt;
  # Send this form for image to image controller with request_id of this request
  &lt;%= form_for [@request, @request.response_images.build], url: url_for(action: 'create_for_request') do |f|  %&gt;
  &lt;p&gt;
  </code></pre>
  
  <p>images_controller.rb:</p>
  
  <pre><code>  def create_for_request    
      @request = Request.find(params[:request_id])    
      if @request          
        @image = Image.new(image_params)
        add_file_params(@image)
        @image.request = @request
        if @image.save       
          redirect_to request_path(@request)
        end     
      else
       #TODO show error no such request 
      end
    end  
  </code></pre>
  
  <p>Any help would be appreciated</p>