Playing with Dry Scaffold and Inherited Resources

There are several ways to start a new Rails project nowadays, specially since Rails brought project templates to the mix. On the other hand there are still lot’s of generators. So, today I want to just pinpoint some tips on this regard.

Notice that I am referring to Ryan Bates’ Nifty Generators. I really like it’s initial CSS and layout to start a new project instead of the default ‘blank’ theme. But that’s just me :-)

The excellent Formtastic will create your scaffolded views with a bit more of web semantics, so it’s highly recommended to use. To make it look pretty, add the following to your ‘app/views/layouts/application.html.haml’:

By default, it’s going to create thin controller with Inherited Resources and paginated with Will Paginate. The view templates will use HAML and Formtastic for a semantically rich form. It will create tests using the standard test/unit and fixtures, but I’d rather choose Rspec and Factory Girl.

It’s also going to generate a separated “_form” partial that both “new” and “edit” views will use, which is one of those things that you do all the time after a normal scaffold. The usage of HAML is not very common, but I would recommend everybody to at least try it for a while, it will grow on you quickly. And having well formatted HTML outputs is always nice.

The Dry Scaffold also supports generating just models (“./script/generate dry_model”). Read the documentation on the github project site to understand all the options.

With this, you should be good to go and start to rapidly prototype your next web application.