ActiveRecord query methods response - need to demistify
Intro: Rails 3.2; 'a' is an object, and ActiveRecord model, which has_many
messages (also ActiveRecord models) - though that's probably not very
important for my question.
So here's the question: why this,
irb(main):046:0> a.messages.respond_to?(:where) => true
but then also this,
irb(main):047:0> a.messages.methods.include?(:where) => false
?
What's happening? Obviously some Ruby magic here, which makes these tho
ways of exploring the object yield different result; one is querying the
Array class, I guess, and the other is querying... that thing which
responds to :where (among other methods). Don't even know what to call it.
My guess is it's querying the object of Array class with some stuff...
'mixed in'? (think I heard that term used in Ruby context a lot...)
No comments:
Post a Comment