Action_link that only runs a function (no view)

15 views
Skip to first unread message

duker_48

unread,
Sep 22, 2011, 9:46:02 AM9/22/11
to ActiveScaffold : Ruby on Rails plugin
Hey I'm looking into creating a password reset action link for a users
list and was wondering if its possible to just have the action link
run the reset password function and not render a new view. I want to
just stay on the users list page, and maybe have the a success message
show at the top.

Atastor

unread,
Sep 22, 2011, 1:19:51 PM9/22/11
to actives...@googlegroups.com
Well...usually I finish such actions with something like

params[:id]=nil
params[:action]=:index
render(params)

or such...not very elegant, but it does the trick...


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

unread,
Sep 26, 2011, 5:14:25 AM9/26/11
to actives...@googlegroups.com

Set position of action link to nil, so ActiveScaffold doesn't expect request
return a view. In the action you can use render :nothing => true, or render
javascript code to show a successful or error message.

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

Atastor

unread,
Sep 26, 2011, 5:34:56 AM9/26/11
to actives...@googlegroups.com
Thanks Sergio! 

I used your answer, to enhance the Wiki explanation of action_links position-parameter, could you take a look?



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

unread,
Sep 26, 2011, 5:46:25 AM9/26/11
to actives...@googlegroups.com

It's ok, thanks for improving wiki

Atastor

unread,
Sep 26, 2011, 6:07:50 AM9/26/11
to actives...@googlegroups.com
Great, my first :-)

Reply all
Reply to author
Forward
0 new messages