The command I’m trying to execute from the terminal:
curl "http://acme.example.com/controller_name/destroy.xml?api_key=123&id=150&other_id=430"
Just a simple GET request, nothing special there.
But when I do that, I get this error:
ActionController::RoutingError
(No route matches "/controller_name/destroy.xml" with
{:remote_ip=>"127.0.0.1",
:accepts=>"*/*",
:protocol=>"http://",
:subdomain=>"acme",
:method=>:get,
:request_uri=>"/controller_name/destroy.xml?api_key=123&id=150&other_id=430",
:port=>80,
:content_type=>nil,
:domain=>"example.com"}):
So then I added this to my routes.rb file:
map.connect "/controller_name/destroy", :controller => :controller_name, :action => :destroy
But I get the same error, so the route I added doesn’t help at all.
Here is the destroy method from controller_name
def destroy
@other = Other.find(params[:other_id])
attachment = @other.attachments.find(params[:id])
attachment.destroy
@attachments = @other.attachments
respond_to do |format|
format.xml do
head :ok
end
end
end
In routes.rb, the controller_name is just included this way:
map.resources :others, :has_many => [:controller_names]
and all the AJAX things already in the controller work fine… even for the same method, calling destroy with an AJAX request works…. but not the XML portion….. >_<
Looks like you are missing the format on the request.