title: How should I pass the ID into collection routes?
body: <p>I am new in ruby on rails.. When the user click the buy button to the specific product, it will get the id of the product then it will redirect to another page where it will display all the details of the product(name,description,price,image etc)..</p>
  
  <p>I created a custom routes which is this one below:</p>
  
  <p><strong>Routes</strong></p>
  
  <pre><code>resources :products do // products is my name of the controller
      collection do
          get :details
      end
    end
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%= button_to 'Add to Cart',details_products_path, class: 'btn btn-primary', method: :get %&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>class ProductsController &lt; ApplicationController
    def index
      @products = Product.all()
    end
    def details
      @product = Product.find(params[:id])
    end
  
  end
  </code></pre>
  
  <p>NOTE: I also check my rake routes, the path it shows </p>
  
  <pre><code>details_products_path   GET /products/details(.:format) products#details
  </code></pre>
  
  <p>I notice that there's no id(like this /products/details/:id) </p>
  
  <p>I also tried this one </p>
  
  <pre><code>&lt;%= button_to 'Add to Cart',details_products_path(@products), class: 'btn btn-primary', method: :get %&gt; 
  </code></pre>
  
  <p>but im getting error </p>
  
  <blockquote>
    <p>"ActiveRecord::RecordNotFound in ProductsController#details" Couldn't find Product with 'id'= in</p>
  </blockquote>
  
  <pre><code>def details
    @product = Product.find(params[:id])
  end
  </code></pre>
  
  <p>Question: How do I pass the ID into my details method that is located at my products controller</p>