Right now I'm storing the user who last updated the state of my model in the state_last_updated_by_id
field and the time the state was last updated in the state_updated_at
field. Then I define methods like this:
def published_at
return unless state == 'published'
state_updated_at
end
def published_by
return unless state == 'published'
state_last_updated_by
end
def nominated_for_publishing_at
return unless state == 'under_review'
state_updated_at
end
def nominated_for_publishing_by
return unless state == 'under_review'
state_last_updated_by
end
This clearly won't scale (and isn't a great approach to begin with) -- what's the right way to do this?