Monday, 26 August 2013

self vs non-self in instance method

self vs non-self in instance method

Why the first code (with self) works but the second doesn't?

category_uri is the attribute of model
def set_uri
self.category_uri = self.category_uri.join('-').downcase
self.save!
end
Without self
def set_uri
category_uri = category_uri.join('-').downcase
save!
end

No comments:

Post a Comment