I create an object c.
Now, if I call c.xxx, ruby just raise an exception 'method missing'
But, I want it return nil, for each method which is not pre-defined.
Is there a way I can gain this ?
If you are doing something like this s = c.xxx then u can always give
recue nil which would then set the value of s as nil.
I imaged there may be some trigger, open it, then object of some class
will response to every method. close it, then exception raises.
I wanna the classes predefined by ruby/rails can have this
Can anyone tell me how to diy it ?
For example, I want a model class has this kind of trigger.
Then I think yo need to write your custom method_missing in you model
class. This is how rails actually creates its dynamic finders by
invoking method_missing in base.rb. Or you can actually modify the
method_missing in base.rb as per your need.
Thank very much!
That's just I want.
I lack of knowledge about how rails works, I think.
Thanks a lot!!