Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ca97e182e1
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (17 sloc) 2.883 kb

Could RewriteRails Make ActiveRecord Mundane?

A thought crossed my mind: Many people complain about Ruby on Rails' use of "magic," things like all of the automatically generated methods and so forth. The most obvious cases are controllers and ActiveRecord models (from here in I'll call these "models" even though we both know you can have models that are not ActiveRecord instances).

Consider model classes. A few declarations... acts_as_inscrutable, acts_as_magical... And the model class gains a whole bunch of class and instance methods, plus often a whole bunch of method_missing behaviours that "behave like" methods. Some people complain it is hard to figure out what methods a model really has.

What if RewriteRails were to rewrite ActiveRecord model class declarations to "mundane-ify" these magical methods? In other words, after a class has been loaded and all of the magic performed, RewriteRails writes out a .rb file that has the source code for all of the magic methods as if the programmer had written them in by hand.

This .rb file can be placed somewhere that Rails can't find it, this is a case of documentation. Now a programmer can read the mundane-ified .rb file to get an idea of what methods the model class actually has.

Just a thought...

My recent work:

JavaScript AllongéCoffeeScript RistrettoKestrels, Quirky Birds, and Hopeless Egocentricity

(Spot a bug or a spelling mistake? This is a Github repo, fork it and send me a pull request!)

Reg Braithwaite | @raganwald

Jump to Line
Something went wrong with that request. Please try again.