@new_record_before_save

Is there an easy way to access the ActiveRecord @new_record_before_save attribute?

Thanks, Tom

Is there an easy way to access the ActiveRecord @new_record_before_save attribute?

Maybe...

>> u = User.new >> u.new_record? => true

Well, it depends on what you mean by easy.

model.instance_variable_get('@new_record_before_save') will work

If you're using an older ActiveRecord and you are trying to tell the difference between a find_or_create_by_..., You can "rely" on the deprecated model.new_record?.nil? to know that it was a find (model.new_record? == false means it was actually a create)

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com