This link has been bookmarked by 22 people . It was first bookmarked on 05 Aug 2007, by Harjeet Singh.
-
20 Jul 10
-
18 Nov 09
-
02 Mar 09
-
11 Nov 08
-
02 Sep 08
-
17 Aug 08
-
26 Jun 08
-
18 Jun 08
Brennan O'KeefeRails implements some of its funkiest magic with method_missing.
-
31 Jan 08
-
10 things you should know about method_missing
Posted by amy on August 01, 2007
[update, 9:27 a.m., 8/1/2007: welcome, reddit readers. annoyed at me for calling this post “10 things”? Well, then you’ll really hate me after reading this post!]
1.
method_missingis a Ruby kernel method and everyone should know about it.2. Rails implements some of its funkiest magic with
method_missing. When you ask your model to find_by_freaky_column_name, and it does so, that’s because ActiveRecord::Base overrides the kernel’smethod_missing method.3.
method_missingis the method of last resort. When you send a message to a Ruby object, Ruby looks for a method to invoke with the same name as the message you sent. (There are a bunch of different ways to send the message, but the most common one is justobj.method_name.But you can make the fact that you are sending a message explicit by usingobj.send(:method_name)). First it looks in the current self object’s own instance methods. Then it looks in the list of instance methods that all objects of that class share, and then in each of the included modules of that class, in reverse order of inclusion. Then it looks in that class’s superclass, and then in the superclass’s included modules, all the way up until it reaches the class Objec
-
-
27 Oct 07
-
13 Aug 07
-
06 Aug 07
-
03 Aug 07
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.