> > > class Unit < ActiveRecord::Base > > > > def name= name > > @name = name + 'bla bla' > > end > > > > end > > > > In Ruby I could do this, but this doesn't affect my object at all... > > The key thing is that ActiveRecord attributes aren't instance > variables. You can use write_attribute to write to the store of > attributes.
"This method is deprecated on the latest stable version of Rails. The last existing version (v1.2.6) is shown here." http://apidock.com/rails/ActiveRecord/Base/write_attribute I'm sure I've seen it in later versions, but thought I'd post it anyway. If it is deprecated, another way is: self.attributes['name'] = name + 'blah blah' It's not exactly the same as write_attribute (it doesn't typecast to numbers for numeric columns) but it will work the same in your case. Cheers, Andy -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

