Acts_as_modified Plugin
0
Sometimes when you are dealing with some of your models, you ask yourself has this model changed? if so then, which attributes? and what were their values before that change?
When should you care about these questions?
Suppose you have a model doing an expensive operation before saving. This operation is useful only if one specific attribute changed, so doing it on every save, neglecting which attributes have changed, will degrade performance significantly.
So what can you do?
You can load the model's old data from Database and check if that attribute has changed or not, and, if it has, perform your action.Or,you can use acts_as_modified plugin; it helps keeping modified attributes with their old values within a model in order to be capable of answering your questions without doing any extra database trips.
Where can I get this from?
It depends on your Rails version:
- 1. ((rails 2.1)) :Do nothing; dirty objects are already embedded in this version
2. ((rails r7315 and above)): Install from
http://svn.viney.net.nz/things/branches/acts_as_modified_edge
3. ((ELSE)): Install from
http://svn.viney.net.nz/things/rails/plugins/acts_as_modified
That's it; enjoy the fun!
Written By:
Osama Brekaa (http://bionuc-tech.blogspot.
Post a Comment
eSpace podcast Prodcast
Archive
- September 2011
- April 2011
- March 2011
- December 2010
- November 2010
- September 2010
- August 2010
- July 2010
- June 2010
- April 2010
- March 2010
- November 2009
- October 2009
- September 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- November 2008
- October 2008
- September 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- January 2008
- April 2007
- March 2007
Latest Comments
- SpectraMind Commented on Egypt Wins UK's National Outsourcing Association Award
- Rofaida Awad Commented on Go Egypt Go!
- Different Mike Commented on Only idiots change their iPhone root password!
- Mike Commented on Only idiots change their iPhone root password!
- smile Commented on Only idiots change their iPhone root password!

