Created
May 9, 2012 11:28
-
-
Save gnufied/2643875 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 SaveFromAfterCommitBlockTest < ActiveRecord::TestCase | |
class TopicWithSaveInCallback < ActiveRecord::Base | |
self.table_name = :topics | |
after_commit :cache_topic, :on => :create | |
def cache_topic | |
puts "******************* calling this stuff again #{cached.inspect}" | |
unless cached | |
self.cached = true | |
self.save | |
else | |
self.cached = false | |
end | |
end | |
def cached=(value) | |
@cached = value | |
end | |
def cached | |
puts "returning #{@cached.inspect}" | |
@cached | |
end | |
end | |
def test_after_commit_in_save | |
t = TopicWithSaveInCallback.new() | |
t.save | |
puts "I am here" | |
end | |
end | |
Author
gnufied
commented
May 9, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment