latest commit breaks deleting a record?

4 views
Skip to first unread message

Courtland

unread,
Jul 16, 2009, 2:19:13 PM7/16/09
to ActiveScaffold : Ruby on Rails plugin
Hi,

Possible heads up here. Using the latest master branch with rails
2.3.2, I am unable to delete a record from within a scaffold's list
view. I receive an ActionController::UnknownAction exception. Rolling
back to the previous commit in active_scaffold master branch seems to
fix the problem for me, thus I am running that for now.

http://github.com/activescaffold/active_scaffold/commit/081ec6367c27cea80aa667aa484ab50d3af0e883#comment_25536

Processing Admin::Scaffolds::UsersController#64 (for 127.0.0.1 at
2009-07-16 11:12:49) [DELETE]
Parameters: {"eid"=>"77a75ba90091a7c137efb8b09c3f7009",
"authenticity_token"=>"G6rRnB+m4yhyzcuHdRbB64t6KuqrnXQuWAqwd3zbdEc="}
Admin Load (0.4ms) SELECT * FROM "admins" WHERE ("admins"."id" =
1) LIMIT 1
AdminRole Load (0.3ms) SELECT * FROM "admin_roles" WHERE
("admin_roles"."id" = 1)

ActionController::UnknownAction (No action responded to 64. Actions:
add_existing, attributes_hash_is_empty?, batch_destroy,
before_create_save, client_ip, client_mac, create, delete, destroy,
destroy_existing, edit, edit_associated, export,
find_or_create_for_params, index, init_session_var, last_action_name,
last_controller_path, list, nested, new, new_existing,
redirect_to_last_controller_index, render_field, row, show,
show_export, show_search, store_action_name, store_controller_path,
table, update, update_column, update_record_from_params, and
update_table):

David Cato

unread,
Jul 16, 2009, 4:10:30 PM7/16/09
to Courtland, ActiveScaffold : Ruby on Rails plugin
Courtland wrote ...

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

Sergio Cambra .:: entreCables S.L. ::.

unread,
Jul 17, 2009, 3:46:54 AM7/17/09
to actives...@googlegroups.com
Do you have in your routes the active_scaffold option?
map.resources :users, :active_scaffold => true

>
>
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com

Sergio Cambra .:: entreCables S.L. ::.

unread,
Jul 17, 2009, 4:05:03 AM7/17/09
to actives...@googlegroups.com
On Jueves, 16 de Julio de 2009 20:19:13 Courtland escribió:
> Hi,
>
> Possible heads up here. Using the latest master branch with rails
> 2.3.2, I am unable to delete a record from within a scaffold's list
> view. I receive an ActionController::UnknownAction exception. Rolling
> back to the previous commit in active_scaffold master branch seems to
> fix the problem for me, thus I am running that for now.

What url you get in the link?


>
> http://github.com/activescaffold/active_scaffold/commit/081ec6367c27cea80aa
>667aa484ab50d3af0e883#comment_25536
>
> Processing Admin::Scaffolds::UsersController#64 (for 127.0.0.1 at
> 2009-07-16 11:12:49) [DELETE]
> Parameters: {"eid"=>"77a75ba90091a7c137efb8b09c3f7009",
> "authenticity_token"=>"G6rRnB+m4yhyzcuHdRbB64t6KuqrnXQuWAqwd3zbdEc="}
> Admin Load (0.4ms) SELECT * FROM "admins" WHERE ("admins"."id" =
> 1) LIMIT 1
> AdminRole Load (0.3ms) SELECT * FROM "admin_roles" WHERE
> ("admin_roles"."id" = 1)
>
> ActionController::UnknownAction (No action responded to 64. Actions:
> add_existing, attributes_hash_is_empty?, batch_destroy,
> before_create_save, client_ip, client_mac, create, delete, destroy,
> destroy_existing, edit, edit_associated, export,
> find_or_create_for_params, index, init_session_var, last_action_name,
> last_controller_path, list, nested, new, new_existing,
> redirect_to_last_controller_index, render_field, row, show,
> show_export, show_search, store_action_name, store_controller_path,
> table, update, update_column, update_record_from_params, and
> update_table):
>
>

Courtland

unread,
Jul 17, 2009, 7:07:36 PM7/17/09
to ActiveScaffold : Ruby on Rails plugin
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.

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

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'

map.connect '*anything', :controller => 'redirector', :action =>
'index'

end

Simplifying my routes to contain the following does not help either...

ActionController::Routing::Routes.draw do |map|

map.resources :users
map.resources :users, :active_scaffold => true

map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id'

end

Note that my scaffold controller does not inherit directly from
ApplicationController. Could that be part of the problem?

app/controllers/admin/scaffolds/users_controller.rb

class Admin::Scaffolds::UsersController < Admin::ScaffoldsController
active_scaffold :user do |config|
...
end

On Jul 17, 1:05 am, "Sergio Cambra .:: entreCables S.L. ::."
<ser...@entrecables.com> wrote:
> On Jueves, 16 de Julio de 2009 20:19:13 Courtland escribió:
>
> > Hi,
>
> > Possible heads up here. Using the latest master branch with rails
> > 2.3.2, I am unable to delete a record from within a scaffold's list
> > view. I receive an ActionController::UnknownAction exception. Rolling
> > back to the previous commit in active_scaffold master branch seems to
> > fix the problem for me, thus I am running that for now.
>
> What url you get in the link?
>
>
>
>
>
> >http://github.com/activescaffold/active_scaffold/commit/081ec6367c27c...

David Cato

unread,
Jul 17, 2009, 8:34:31 PM7/17/09
to Courtland, ActiveScaffold : Ruby on Rails plugin
Courtland wrote ...

> 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

Courtland

unread,
Jul 29, 2009, 12:36:14 AM7/29/09
to ActiveScaffold : Ruby on Rails plugin
Properly namespacing the route resources as you suggested seems to fix
the delete problem. Thanks a bunch.

Is this to say that active_scaffold has moved away from supporting the
old school default routes and will only work when using RESTful
routes? The wiki on github still implies that this is optional. I
would just like to understand what the correct approach is and why, as
I have been using active_scaffold without the additional route
resources for some time now, and I have quite a few models/scaffolds
in my application.

On Jul 17, 5:34 pm, David Cato <o...@crunchyfrog.net> wrote:
> Courtland wrote ...
>
> > The generateddeleteURL is.
>
> >http://localhost:3000/admin/scaffolds/users/delete/64?_method=delete&...

Sergio Cambra .:: entreCables S.L. ::.

unread,
Jul 29, 2009, 11:57:02 AM7/29/09
to actives...@googlegroups.com
On Miércoles, 29 de Julio de 2009 06:36:14 Courtland escribió:
> Properly namespacing the route resources as you suggested seems to fix
> the delete problem. Thanks a bunch.
>
> Is this to say that active_scaffold has moved away from supporting the
> old school default routes and will only work when using RESTful
> routes? The wiki on github still implies that this is optional. I
> would just like to understand what the correct approach is and why, as
> I have been using active_scaffold without the additional route
> resources for some time now, and I have quite a few models/scaffolds
> in my application.

I think it was optional because RESTful routes was added later to rails, and
we had support for old rails versions. However, latest branches only support
new rails versions, and default routes are not recommended. It's harder
support old default routes and RESTful routes, and we are thinking to move
nested scaffolds to use nested routes, so I don't think we support default
routes in a future (or even currently).

Courtland

unread,
Jul 29, 2009, 12:27:29 PM7/29/09
to ActiveScaffold : Ruby on Rails plugin
Good to know thanks.

On Jul 29, 8:57 am, "Sergio Cambra .:: entreCables S.L. ::."

Nick Rogers

unread,
Aug 3, 2009, 5:03:08 AM8/3/09
to ActiveScaffold : Ruby on Rails plugin
FYI more discussion and followup "fix" here...

http://github.com/activescaffold/active_scaffold/issues/closed/#issue/40

On Jul 29, 9:27 am, Courtland <ncrog...@gmail.com> wrote:
> Good to know thanks.
>
> On Jul 29, 8:57 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> <ser...@entrecables.com> wrote:
> > On Miércoles, 29 de Julio de 2009 06:36:14 Courtland escribió:
>
> > > Properly namespacing the route resources as you suggested seems to fix
> > > the delete problem. Thanks a bunch.
>
> > > Is this to say that active_scaffold has moved away from supporting the
> > > old school default routes and will only work when usingRESTful
> > > routes? The wiki on github still implies that this is optional. I
> > > would just like to understand what the correct approach is and why, as
> > > I have been using active_scaffold without the additional route
> > > resources for some time now, and I have quite a few models/scaffolds
> > > in my application.
>
> > I think it was optional becauseRESTfulroutes was added later to rails, and
> > we had support for old rails versions. However, latest branches only support
> > new rails versions, and default routes are not recommended. It's harder
> > support old default routes andRESTfulroutes, and we are thinking to move
> > > > withRESTfuland named routes only.
Reply all
Reply to author
Forward
0 new messages