Ian White wrote:
> Hi Core List,
>
> Sometimes I'm required to keep track of whether an activerecord object  
> was succesfully saved.
>
> A case in point would be doing something in an after_filter of a  
> controller.  For example, I might want to keep track of how many times  
> users post invalid active records.
>
> One way of doing this would be to use #valid?, but this will hit the  
> database again in some cases (e.g. if there's a  
> validates_uniqueness_of), which I want to avoid.
>
> I'm proposing a very simple API, as described here 
> http://www.pastie.org/268045 
> .
> To make this work is also very simple (here's a plugin verision 
> http://pastie.org/268046) 
> .
>
> Before I bundle this up into a patch with tests, I'm wondering if  
> people think this is a good or bad idea?
>   
Could something be done with with the change tracking in 2.1?

How about:
!(model.new_record? || model.changed?)

This would only be true if the record was saved or it was an update with 
no changes.

Jack
> Cheers,
> Ian
>
> --
> Argument from Design--We build web applications
> Western House 239 Western Road Sheffield S10 1LE
> Mob: +44 (0)797 4678409 | Office: +44 (0)114 2667712
> <http://www.ardes.com/> | <http://blog.ardes.com/ian>
>
>
>
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to