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
>
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/callbacks.rb:346:
> 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 "?".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---