Looks like your routes might be messed up somehow.
I'm not experiencing any problems with the latest master branch. The
same action produces the expected results for me.
Processing Admin::UsersController#destroy (for 127.0.0.1 at 2009-07-16
12:54:20) [DELETE]
Parameters: {"action"=>"destroy",
"authenticity_token"=>"lqufCBgIloycQOLhTS1Wm6fgKXmBb8X+uyWUMiLlyRY=",
"_method"=>"delete", "id"=>"42", "controller"=>"admin/users"}
... [eliding DB logs]
Rendering destroy
Rendered _messages (1.6ms)
Completed in 225ms (View: 32, DB: 116) | 200 OK
[http://localhost/admin/users/42?_method=delete&authenticity_token=lqufCBgIloycQOLhTS1Wm6fgKXmBb8X%2BuyWUMiLlyRY%3D]
Somthing different in our models? My app uses restful_authentication and
the User model is pretty simple:
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
has_many :news_items, :foreign_key => 'author_id'
has_many :passwords, :dependent => :destroy
has_and_belongs_to_many :roles
...
end
> The generated delete URL is.
>
> http://localhost:3000/admin/scaffolds/users/delete/64?_method=delete&authenticity_token=G6rRnB%2Bm4yhyzcuHdRbB64t6KuqrnXQuWAqwd3zbdEc%3D
>
> This does look like a routing problem of sorts. I did not have the
> "map.resources :users, :active_scaffold => true" in my routes, but
> adding such does not change the resulting URL nor does it resolve the
> exception.
Since you've namespaced your controller, you need to namespace the route
too. One possibility would be
map.namespace(:admin) do |admin|
admin.namespace(:scaffold) do |scaffold|
scaffold.resources :users, :active_scaffold => true
...
end
end
I've never tried a two-level namespace before so there might be a
simpler way to specify the routes, but I couldn't come up with anything
else that worked.
> Here are my routes.
>
> ActionController::Routing::Routes.draw do |map|
>
> map.root :controller => 'redirector', :action => 'index'
>
> map.resources :users
> map.resources :users, :active_scaffold => true
These would be for the top-level users controller, probably for things
like account signup and such. Since your admin controller is namespaced,
you need to remove, at least, the one with :active_scaffold => true.
> map.resources :admins
> map.resource :admin_session, :controller => '/admin/sessions'
>
> map.connect '/admin', :controller => '/admin/menu', :action =>
> 'instruments'
>
> map.connect ':controller/:action/:id.:format'
> map.connect ':controller/:action/:id'
Unless you have a really good reason for keeping these last two
old-style default routes, you're better off removing them and sticking
with RESTful and named routes only.
> map.connect '*anything', :controller => 'redirector', :action =>
> 'index'
>
> end
From my working routes.rb with a single-level admin namespace, leaving
out the unrelated routes,
ActionController::Routing::Routes.draw do |map|
# For the public side (user signup, password change, etc.)
map.resources :users, :member => { :change_password => :get, :update_password => :put }
# For the admin side
map.namespace(:admin) do |admin|
admin.resources :users, :active_scaffold => true
end
end