R
Raj Singh
class User < ActiveRecord::Base
def before_save
self.name1 = fname + ' ' + lname
name2 = fname + ' ' + lname
end
end
In the callback I am using self for name1 and NOT using self for name2.
When a record is saved in the database I get proper value for name1 but
not for name2. Question is why?
In my judgement before name2 whether I use self or not should not matter
because there is an implicit self when there is no receiver. Then why
the difference in behavior?
def before_save
self.name1 = fname + ' ' + lname
name2 = fname + ' ' + lname
end
end
In the callback I am using self for name1 and NOT using self for name2.
When a record is saved in the database I get proper value for name1 but
not for name2. Question is why?
In my judgement before name2 whether I use self or not should not matter
because there is an implicit self when there is no receiver. Then why
the difference in behavior?