removed the if request.post? because it is impossible for it not to
be a POST request. The route specifies :post, there is no
delete_selected view to render if it is notPOST, and this is only
reached via a form post from mails/index.
change flash.now[:success] to flash[:success]. flash.now only
displays if we immediately render after the action. It will be cleared
before it gets a chance to display if we redirect, which is what we're
doing. flash[:success], on the other hand, is only cleared after the
redirect.
switched the redirect at the tend to redirect to mails/index. It was
trying to redirect to mails/show, but passing in an instance variable
that is not defined. mails/show expects only a single mail, anyway. It
seems like we probably want to redirect to the index action instead
after deleting, since the mails are no longer there to show.
It appears that the :conditions is not necessary with Mail.find
because @mail.mark_deleted only changes the record based on the
relationship the user has to the mail. If the user is not the sender or
recipient, then it will not be changed.
if request.post?
because it is impossible for it not to be aPOST
request. The route specifies:post
, there is nodelete_selected
view to render if it is notPOST
, and this is only reached via a form post frommails/index
.flash.now[:success]
toflash[:success]
.flash.now
only displays if we immediately render after the action. It will be cleared before it gets a chance to display if we redirect, which is what we're doing.flash[:success]
, on the other hand, is only cleared after the redirect.mails/index
. It was trying to redirect tomails/show
, but passing in an instance variable that is not defined.mails/show
expects only a single mail, anyway. It seems like we probably want to redirect to theindex
action instead after deleting, since the mails are no longer there to show.:conditions
is not necessary withMail.find
because@mail.mark_deleted
only changes the record based on the relationship the user has to the mail. If the user is not the sender or recipient, then it will not be changed.