Routing error for custom POST route in Rails 3

I’ve been banging my head against this for a while, and would love to
see someone prove that I am just overlooking something simple.

I am trying to add a custom route to my RESTful resource. Because
route is destructive, I want to use “POST” http method. If I hack my
routes.rb to use GET, everything works just fine:

2 different server runs, only difference is get vs. post in my
routes.rb

Started POST “/maps/1/reload_from_deamon” for 127.0.0.1 at Sun Oct 17
23:17:32 -0700 2010
ActionController::RoutingError (No route matches “/maps/1/
reload_from_deamon”):

Started GET “/maps/1/reload_from_deamon” for 127.0.0.1 at Sun Oct 17
23:26:53 -0700 2010
Processing by MapsController#reload_from_deamon as HTML

Here are my symptoms:

routes.rb
resources :maps do
member do
post ‘reload_from_deamon’
end
end

i’ve also tried

resources :maps do

post ‘reload_from_deamon’, :on => :member

and

match ‘maps/:id/reload_from_deamon’ =>

“maps#reload_from_deamon”, :via => :post

MapsController
def reload_from_deamon
@map = Map.find(params[:id])
status = @map.reload_from_deamon
redirect_to @map, :notice => status
end

I generate my post form as following, this might be what is killing
me. I’ve been unable to coerce form_for to generate the proper POST
url for me.

<%= form_for @map, :url => map_path(@map)+ “/reload_from_deamon” do |
f| -%>

Refresh readers from deamon

<% end -%>

Any ideas?

Aleks
Aleks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs