Displaying 1 result from an estimated 1 matches for "set_permalink".
2007 Jul 01
1
ActiveRecord: why does 'self.name' and 'name' both work?
I''m trying to figure out why both ''self.name'' and ''name'' work in a
model class. For example:
class Category < ActiveRecord::Base
before_save :set_permalink
private
def set_permalink
# both work
self.permalink = name
self.permalink = self.name
# doesn''t work
permalink = name
@permalink = name
@permalink = @name
self.permalink = @name
end
end
I thought that attributes in a class were set via instance metho...