Today I would like to introduce a new option for Create, Delete and Update Action named ‘refresh_list’. The purpose is to refresh the whole list after corresponding action, which might be quite useful, especially if action has also side effects on sibling records.
In addition records are inserted according to current sorting after update/create operations. However, disadvantages are higher server load and that you may not see inserted/updated records in result view.
Configuration is fairly easy. Let s change my famous players controller to activate this new feature:
class PlayersController < ApplicationController active_scaffold :player do |conf| .... conf.create.refresh_list = true conf.update.refresh_list = true conf.delete.refresh_list = true .... end end
If you would like to enable it for all controllers, you may do the following:
class ApplicationController ActiveScaffold.set_defaults do |conf| conf.create.refresh_list = true end end
hani elabed
Jun 04, 2011 @ 07:40:59
Hi Volker,
I googled for CRUD and refresh list for activescaffold and got this page. I added the 2 lines needed for create/update to my activescaffold config and it worked like a charm.
Thank you for this wonderful feature… And a belated thank you for activescaffold on RAILS 3, and all the wonderful blogs on this site…
I recently upgraded another large project from Rails 2 to Rails 3 with activescaffold and your gem for Rails 3 worked like a charm with prototype support. Thank you again.
Hani Elabed
Verona, Wisconsin, USA
Antonio Molinari
Jul 14, 2011 @ 02:53:35
hi, ive added a custom action such this:
config.action_links.add ‘approve’, :label => I18n.t(“approve”), :confirm => I18n.t(“confirm approve”), :type => :member, :method => :put, :position => false, :refresh_list => true
how can i “force” the row refresh within my:
render :update do |page|
(???)
end
thank you very much!
vhochstein
Jul 14, 2011 @ 13:34:18
I would suggest reading this post :https://vhochstein.wordpress.com/2010/12/03/activescaffold-confirmation-of-actionlinks/
should show you an example how to respond to actionlink s correctly
Antonio Molinari
Jul 14, 2011 @ 23:26:28
thank you, i’ve tried, flash[:info] works and te row “highlight” itself in yellow as usual but no data is updated 😦
i simply do a @card.update_attribute(:approved,true) but the checkbow in activescaffold list doesn’t get checked for that specified row, to see it correctly i’ve got to refresh the netire browser page: how can i force the refresh of the as row with the just updated attributes correctly displayed ?
vhochstein
Jul 15, 2011 @ 11:54:54
Well, can just tell you that it works for me.
Christoph
Jun 26, 2013 @ 13:09:50
Hi,
Is it posible to refresh the whole page on certain actions?
thx
vhochstein
Jun 26, 2013 @ 16:55:39
Well if this is a simple action (no form such as search involved) Do not trigger that action via ajax and do a redirect on server side