Peeking behind the curtain and seeing what makes the so-called "magic" tick is easy.
I'm in a Rails app which has ActiveRecord User models, each of which has an association class specified:
I install the gem, and then I call
And Ruby2Ruby returns the class, translated from an object in memory into Ruby code.
In terms of the methods I get back, there are several association-related methods, and one class method I defined when creating the class itself. Conspicuously absent are methods like
save- that's because they live on
Unfortunately, when you call
...things kind of blow up. The same is true for
ActionController. For some reason, just as it can show you
ActiveRecord::Base, it can show you
ActionController. Ruby2Ruby can apparently only reveal some of the magic you might want to see.
But it's still a handy trick. Many Rails plugins of the
acts_as_foofamily add methods to models, and you should be able to see those changes with Ruby2Ruby. It's a very useful way to shed some light on what actually happens inside Rails' "magic."