Tag Archives: method_missing

Defining #method_missing and #respond_to? at the same time

I was reading Eloquent Ruby yesterday morning (buy a copy if you haven’t already), and it got me thinking about one of my “favorite” Ruby gotchas: defining #method_missing without a corresponding #respond_to?. E.g.: class Liar def method_missing(*args) “Oops, I lied” … Continue reading

Posted in Stupid Ruby Tricks | Tagged , , , | 24 Comments

ActiveRecord association extensions and method_missing

The semantics of method calls in Ruby are simple: Call the named method; or If no method exists, call #method_missing() instead. Normally #send() obeys these rules as well. ActiveRecord association proxies mangle #send()‘s semantics, however, violating the POLS and potentially … Continue reading

Posted in Ruby | Tagged , , , , , , | 12 Comments