Also I am not sure what rails default is when you just add a
“?”…does it only fail if caption is nil?
I like to do something like this in these scenarios:
def the_caption
self.caption.blank? title : caption
end
I haven’t used read_attribute yet but from the docs it might look
something like this
def caption
caption = read_attribute(:caption)
caption.blank? self.title : caption
end
You get the idea though…just wanted to mention the “blank” part
because if your caption is somehow set to " " I am guessing you want
the title returned.
On Oct 8, 9:43 am, Marnen Laibow-Koser <rails-mailing-l…@andreas-
Afaik it has nothing to do with method missing magic. Its just that if
you overwrite a method, a call to super invokes the original method.
AR injects accessor methods for every table column into the class.
Afaik it has nothing to do with method missing magic. Its just that if
you overwrite a method, a call to super invokes the original method.
Not really. As far as I know, super calls the method of the same name in the parent class, which isn’t always the same thing. That’s why we
have alias_method_chain – it wouldn’t be necessary if super worked the
way you claim.
AR injects accessor methods for every table column into the class.
But into the model class itself, not AR::Base. There is no
AR::Base#caption method for super to call. I suspect that super simply
triggers AR’s method_missing, which happens to do the right thing in
this case. But that shouldn’t be relied on as a general rule c