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| -%>
        <button type="submit" class="button" onclick="document.location = '/
maps/1'">
                <img alt="" src="/images/web-app-theme/icons/
database_refresh.png">Refresh readers from deamon
        </button>
        <% end -%>

Any ideas?

Aleks
Aleks

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to