RESTful Named Routes

Hi,

I'm writing a blog engine using Rails and have removed the default route because I want to use RESTful URLs that have the form /yyyy/mm/dd/slug

I've added some named routes for showing and editing posts that work fine. The problem is that my named route for deleting a post isn't working - the destroy action within my Posts controller is never called. If I run "rake routes" then I notice that my delete_post_by_slug route doesn't have a DELETE method against it.

How can I constrain my delete_post_by_slug route to the HTTP DELETE verb?

Thanks for any help!

John

Below is an extract from my routes.rb file:

map.resources :users map.resources :posts map.resource :session, :controller => 'session'

# Edit map.edit_post_by_slug '/:year/:month/:day/:slug/edit', :controller => 'posts',         :action => 'edit', :requirements => { :year => /\d{4}/,                                        :month => /\d{1,2}/,                                        :day => /\d{1,2}/ }

# Show map.post_by_slug '/:year/:month/:day/:slug', :controller => 'posts',         :action => 'show', :requirements => { :year => /\d{4}/,                                           :month => /\d{1,2}/,                                           :day => /\d{1,2}/ }

# Destroy map.delete_post_by_slug '/:year/:month/:day/:slug', :controller => 'posts',         :action => 'destroy', :requirements => { :year => /\d{4}/,                                               :month => /\d{1,2}/,                                               :day => /\d{1,2}/ }

John,

I think it's just adding: :method => :delete to the destroy definition.

-Danimal

Hi Danimal,

I figured it out. You were pretty much right, but the syntax is :conditions => { :method => :delete }

Thanks for your help!

John

Danimal wrote: