Frederick Cheung wrote in post #978098: > On Jan 28, 2:11am, Marnen Laibow-Koser <[email protected]> wrote: >> Frederick Cheung wrote in post #978021: >> [...] >> >> > I seem to recall that >> > historically, although method_missing etc was overriden to add dynamic >> > methods, respond_to wasn't, which didn't make AR a very good citizen, >> > which may be why this works with projects using old versions of rails >> >> How is that possible? respond_to? shouldn't need to be overridden to >> take method_missing into account, should it? > > The default implementation of respond_to? doesn't know that although a > method (like a attribute accessor) doesn't exist yet, if you were to > call it then method_missing would create it, so respond_to would > return false, even though you would be able to call the method.
Really? I thought I'd used respond_to? in that context successfully. Perhaps I'm wrong or it was overridden. > Need is a vague word. At a basic level you don't need to override > respond_to, however there was a strong enough feeling that this wasn't > consistent, especially as you'd do things lile > > foo.respond_to? :name #=> false > foo.name #=> 'Bob' > foo.respond_to? :name #=> true Right. > > > Fred Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. -- 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.

