title: making a delete request to URL rather than ID in a rails api
body: <p>i'm wondering if anyone can give me any advice.</p>
  
  <p>I'm currently writing a rails API and although it doesn't seem like a best practice, rather than performing a DELETE call to</p>
  
  <pre><code>localhost:3000/products/:id
  </code></pre>
  
  <p>id rather make it to</p>
  
  <pre><code>localhost:3000/products/:url
  </code></pre>
  
  <p>and pass in the URL to be deleted, however i've currently got this but I keep getting a routing error.</p>
  
  <pre><code>DELETE '/products/:url', to: 'products#destroy'
  </code></pre>
  
  <p>is my current route for this, it is also specified above my</p>
  
  <pre><code>resources :products
  </code></pre>
  
  <p>sections.</p>
  
  <p>My whole routes file:</p>
  
  <pre><code>AppName::Application.routes.draw do      
    resources :features do
    resources :feature_links
    end
  
    resources :wishlist_items
  
    resources :data_feeds
    get '/get_data_feeds', to: 'data_feeds#get_feed_url', as: 'feed_url'
  
    resources :genders
  
    resources :trends
  
    resources :sub_categories
  
    resources :color_tags
  
    resources :colors
  
    resources :categories
  
    delete '/products/:url', to: 'products#destroy'
  
    resources :products do
      member do
        get 'buy'
        post 'wish'
      end
    end
  end
  </code></pre>
  
  <p>Any ideas?
  Thanks in advance</p>
  
  <p>If the url i'm sending the delete request to is <code>http://localhost:3000/products/www.test.com</code> I get the error <code>No route matches [DELETE] "/products/www.test.com"</code> if the url I sent the delete request to is <code>http://localhost:3000/products/:url</code> I get the error <code>Couldn't find Product with 'id'=:url</code></p>
  
  <p>My Destroy method code:</p>
  
  <pre><code> def destroy
      @product = Product.find(params[:url])
      @product.destroy
      respond_with(@product, status: 200)
   end
  </code></pre>