Custom actions behavior

1 view
Skip to first unread message

Luke Melia

unread,
Aug 21, 2009, 1:03:33 AM8/21/09
to admin_a...@googlegroups.com
Hey folks,

I'm looking at the behavior demonstrated in:

test_rails_app/app/controllers/admin/
blog_posts_custom_new_and_edit_controller.rb

You'll see that in this controller, there are Controller#new and
Controller#edit methods defined, which admin_assistant sees and
decides to generate a New link and Edit links. This occurs even though
thew :new and :edit actions aren't included in the config.actions
declaration. It treats defining the method as sort of an implicit
configuration.

I have a use case that doesn't work well with this implicit
configuration, so I wanted to see what you all thought about requiring
actions to be in the actions array in order to generate links to them.

Here's my use case:

In my admin area, I want a list of Recommendations (auto-generated by
admin_assistant).
In-context in the content area of my app, I want a user with admin
privileges to be able to create a new recommendation by clicking a
link to a new form with query params that specify the content to be
recommended.
That in-context click is a GET to the :new action of the admin
recommendations_controller, which is triggering the undesired (in my
case) behavior I described above.

Anyone opposed to changing this? Other ideas?

Cheers,
Luke
--
Luke Melia
lu...@lukemelia.com
http://www.lukemelia.com/

Francis Hwang

unread,
Aug 21, 2009, 10:55:41 AM8/21/09
to admin_a...@googlegroups.com
Yeah, the use-case I was trying to support is that at Sling we've had
a lot of times where we want to use admin_assistant for
index/search/pagination/sorting, but the creating/updating is totally
custom and we want to override it.

To make it less implicit, maybe we can have helper methods like
new_link_in_index? and edit_link_in_index? that might return true or
false depending on whether such links should be displayed.

I guess then part of the question is which is a more useful default.
My guess would be that if you define new/edit/create/update, it's a
more useful default to try to stitch that into the generic
admin_assistant flow, with those links, etc. I'd be interested in
hearing other people's opinions though.

FH

Luke Melia

unread,
Aug 22, 2009, 10:20:04 AM8/22/09
to admin_a...@googlegroups.com
I agree with your perspective on the default behavior, Francis. I just
pushed a changeset to the weplay fork which adds helper method hooks
along the lines of what you suggested.

Cheers,
Luke
Reply all
Reply to author
Forward
0 new messages