“I’d rather write programs to write programs than to write programs”. I remember seeing these on t-shirts that some of those geeks use to wear. This precisely is what accounts for the productivity gains of Rails. In addition to this, Rails also creates much of the scaffolding that you need which adds up to the productivity.
Typically, frameworks use extensive code generation, which gives users a one-time productivity boost but very little else, and customization scripts let the user add customization code at a few carefully selected points. Metaprogramming removes the disadvantages of these techniques and Ruby is one of the best metaprogramming languages where a code is used to write codes.
Scaffolding features of rails allows for creating the application quickly and see how the major components work together well.