Well, I can't find the problem, but I guess I have an alternative
solution, and that is to use a new method named Model1.make_deleted()
which does the deletion work. Also, then I should stop destory() from
being executed (by raising some kind of exception in before_destroy()
method).
I guess that shall do the work, but I'm still thinking if there is a
standard way of marking a row as deleted, while not actually deleting
the row, since the above solution doesn't seem to be in compliance
with Rails-way. (Callbacks are made for some purpose after all).


On Jan 16, 8:53 pm, Ilan Berci <[email protected]>
wrote:
> Vikrant wrote:
> > I have a model Model1 with the before_destory() method defined as
> > below.
>
> > def before_destroy
> >  self.status = 'deleted'
> >  self.save!
> >  return false #don't want to delete the row.
> > end
>
> Your transaction isn't completed until the request is completed.  If you
> check your DB, you will not see any changes until the request has been
> completed (assuming that your transaction level is beyond dirty reads)
>
> Secondly, you shouldn't save in a before_destroy filter
>
> I also believe that returning false will abort the transaction and you
> will be left with an unmodified data source.
>
> ilan
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to