access @new_record_before_save

jdf пишет:

is there a way to access a model instance's @new_record_before_save?
method? i haven't been able to figure out how to write a reader for it.
an earlier post here suggested something like this:

before_save("@newly_saved? = new_record?; true")
attr_reader :newly_saved?

but that raises an error on save:

SyntaxError: compile error
parse error, unexpected '='
@newly_saved? = new_record?; true

Instance variables doesn't allow non-alphanumeric characters like "?".

Then "@new_record_before_save?" is not a method. It's an instance variable. Almost. I guess, you mixed "@new_record_before_save" instance variable and "new_record_before_save?" method together.

So, look for the same instance variables, but without "?".