Let's say I have a model User, a model Taskthat has the boolean attribute and a model that is created when the task completes, and belongs_to :userso :has_one :eventdoes .completedEventbelongs_to :event
In TaskObserverI noticed that instead
class TaskObserver < ActiveRecord::Observer
def after_update(task)
def after_update
task.create_event(:user=>task.user) if task.completed?
end
end
I could write
task.create_event(:user_id=>task.user.id)
or even
task.create_event(:user_id=>task.user_id)
While the first method seems the most correct, are there any advantages to using any of the latter options?
source
share