I am trying to update two attributes in a method like this:
def my_method
@from = @to = Time.zone.now
end
but when I call this method I don't get set values in from and to:
my_model.from => nil
my_model.to => nil
with this it works:
self.from = self.to = Time.zone.now
my_model.from => Sat, 20 Jul 2013 20:54:40 UTC 00:00
- do you know why the first way does not work?
- could you give me some advice about the difference between these? how are they called? instance vars or attr_accessors? actually I need help defining this second question.
Update
from
and to
are persisted attributes