Static Typing for Ruby on Rails

David An, Avik Chaudhuri, and Jeffrey Foster

Ruby on Rails (or just ``Rails'') is a popular web application framework built on top of Ruby, an object-oriented scripting language. While Ruby's powerful features help make Rails development extremely lightweight, this comes at a cost: Ruby is dynamically typed, and so type errors in a Rails application can remain latent until run time, making debugging and maintenance harder. In this paper, we describe DRails, a novel tool that brings static typing to Rails applications to detect a range of run time errors. DRails works by translating Rails programs into pure Ruby code in which Rails's numerous implicit conventions are made explicit. We then discover type errors by applying DRuby, a previously developed static type inference system, to the translated program. We ran DRails on a suite of applications and found that it was able to detect several previously unknown errors.


    author = {Jong-hoon An and Avik Chaudhuri and Jeffrey Foster},
    title = {Static Typing for Ruby on Rails},
    booktitle = {Proceedings of the 24th IEEE/ACM
                 Conference on Automated Software Engineering (ASE'09)},
    year = {2009},
    pages = {590--594},
    publisher = {IEEE}