First - in the subject I said "after_save" but meant "after_create"
but the issue is the same. I think I may have just figured it out,
but perhaps you could verify. I have a project model and events
models. When I create a project, I loop through an array that creates
default events. I noticed that all the events were getting created
twice. Here's the Project model:
class Project < ActiveRecord::Base
has_many :events
after_create :after_create
def after_create
## create my default events
end
end
The problem, I think, is that after_create is called automatically,
and you only need to have the "after_create :after_create" line if the
callback is named something besides callback event. Once I took out
the "after_create :after_create" line, it seemed to work. I didn't
try it, but I suppose I could have left it in but named the method
something besides "after_create" like "add_default_events."
So is what I have said correct?
Thanks for taking the time to help me with this.
On Aug 30, 12:26 pm, Frederick Cheung <
frederick.che...@gmail.com>