On May 30, 2008, at 9:32 AM, Jason Roelofs wrote:

> The issue here is that the parser can't tell the difference between
> calling the method #name2= or creating a new local variable named
> "name2"
>
> In this case, the proper course of action is to use "self.name2 = " to
> make sure there is no confusion.
>
> Jason


...and the reason Ruby can't has to do with the dynamic way that  
ActiveRecord provides model attributes.  Ruby can't introspect on the  
object to find that name2= exists so it is quite happy with calling  
name2 a local variable.  If you used name2 on the first line  
(self.name1 = fname + name2) then Ruby would have to assume that name2  
is a method since it would otherwise be an undefined local variable.   
(I don't know if it would then find name2= for the next line, but I  
suspect not.  That would be easy for you to try anyway.)

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com