Hi,
I''ve defined the following model:
class Eintrag < ActiveRecord::Base
before_validation :vali
protected
def vali
# self.feld1.reverse!
self.feld2 = self.feld1
end
end
Now I''m wondering why I have to write
self.feld2=self.feld1
and why
@feld2=@feld1
doesn''t work.
I''ve found the thread
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/3405e38a2f34e896/7cfa3cb86d87d034?lnk=gst&q=callback+self+instance#7cfa3cb86d87d034
But it''s missing the reason.
Thanks,
martin
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-17 18:11 UTC
Re: Callback Problem: Why to use self.var= instead of @var=
On 17 Apr 2008, at 18:39, Martin wrote:> > Hi, > > I''ve defined the following model: > > class Eintrag < ActiveRecord::Base > before_validation :vali > > protected > def vali > # self.feld1.reverse! > self.feld2 = self.feld1 > end > end > > Now I''m wondering why I have to write > self.feld2=self.feld1 > and why > @feld2=@feld1 > doesn''t work.Because activerecord attributes aren''t stored as instance variables. Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- Post-hoc tests for repeated measures in balanced experimental design
- ClamAV reporting virus found in 4.8.3 from source
- cv.glm function error message in a loop
- Samba4 bind DNS
- R 2.0.0: namespaces, S4 classes & versioned package installation: failure to resolve correct pkg version