I wrote a small controller to find all the expired items and destroy
them:
@listtodestroy=Product.find(:all, :conditions => [''user_id = ? AND
date_expires <= ?'', @user.id, Time.now])
for product in @listtodestroy
product.destroy
end
It works fine but there''s no warning that everything is about to be
removed like when I call product.destroy on an id instead of array. Is
there a simple way to call the "Are you sure?" dialog for the above?
Thanks..
--
Posted via http://www.ruby-forum.com/.
Vince W. wrote:> I wrote a small controller to find all the expired items and destroy > them: > > @listtodestroy=Product.find(:all, :conditions => [''user_id = ? AND > date_expires <= ?'', @user.id, Time.now]) > for product in @listtodestroy > product.destroy > end > > It works fine but there''s no warning that everything is about to be > removed like when I call product.destroy on an id instead of array. Is > there a simple way to call the "Are you sure?" dialog for the above? > > Thanks..The confirm dialog needs to go on the form button/link that calls the above controller action. Once the request is fired off to the controller you have no control over it until it renders/redirects. -- Posted via http://www.ruby-forum.com/.
Luke Redpath wrote:> The confirm dialog needs to go on the form button/link that calls the > above controller action. Once the request is fired off to the controller > you have no control over it until it renders/redirects.Bingo. Thank you! -- Posted via http://www.ruby-forum.com/.