Created
May 5, 2010 13:35
-
-
Save tcocca/390769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Recipe < ActiveRecord::Base | |
belongs_to :style, :counter_cache => true | |
attribute_method_suffix '_previous_change' | |
private | |
def attribute_previous_change(attr) | |
self.changes[attr] | |
end | |
end | |
###### | |
@recipe = Recipe.find(1) | |
@recipe.style_id ## => 1 | |
@recipe.style_id = 2 | |
@recipe.save | |
@recipe.style_id_previous_change ## => [1, 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment