This project is archived and is in readonly mode.
objects created by find_or_create_by_ methods do not call after_initalize/after_create
Reported by Adam S | February 7th, 2009 @ 01:20 AM | in 2.x
class MyModel < ActiveRecord::Base
def after_initialize
attrib1 = 'value'
end
end
class MyModelTest < ActiveSupport::TestCase
test "attrib should be value"
test_model = MyModel.find_or_create_by_attrib2('I like cats')
assert_equal 'value', test_model.attrib1
end
end
Comments and changes to this ticket
-
Adam S February 9th, 2009 @ 01:56 AM
Short answer, no.
That will probably work. The confusing thing is that the method above worked some of the time (ie when i didn't use find_or_create_by ;).
Ehhh... guess this ticket can be closed.
-
CancelProfileIsBroken March 8th, 2009 @ 01:08 PM
- State changed from new to invalid
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>