I have been confronted couple of times to similar development tireness – boilerplate over an over. For me boiler plate is all that does not bring any added business value (static: project setup, contextual: CRUD (backend, frontend), drop-down list, sub-Usecase for affectation etc..., etc...)
The approach presented is command line generation of rails scaffold artifacts which has the following pitfalls : incomplete and brittle on maintenance. Generation covers the aspects of generating same information (redundant info) over different type of artifacts (DB storage, presentation layer, persistence layer etc…)
Furthermore consecutive generation overrides your changes.
To solve this inconvenience, I see only two solutions :
Do not use generator but a generic framework that manages in one central place persistence and presentation aspects. In java there is Openxava that is designed for that. It works with annotations (persistence and presentation), it also answers your validation question with stereotype.
Use an updatable-generated-code generator. Minuteproject gets updatable-generated-code feature. You can modify generated parts and the next generation keeps your modifications. Meanwhile none of those solutions matches your technology target (Rails).
Minuteproject can be extended to generate for any text based language (java, ruby, python, c, js…).
Minuteproject generates from DB structure, query statement, transfer-object definition see productivity facet for analysts
Remark : minuteproject also provides a reverse-engineering solution for Openxava
In the sequence summary proposed :
create model, relationship + hooks, I would go rather consider the DB model as a center place and add hooks (not yet present) in model enrichment (minuteproject propose a dedicate to enrich the model with conventions…) I rather go for reverse-engineering solution than Forward engineering for the following reasons :
- correct DB storage is too crucial to be generated :
- Forward engineering cannot generate view, stored procedure, function etc...
- Forward engineering may not tune correctly (tablespace) your persistence model.
generate by picking up your technology target
implements the hooks in updatable-generated-code sections, so that at the next generation (model structure has changed, new hooks are to be implemented), your previous hook-implementations are kept.
I have create some to-be-implementated (hook) for Openxava (http://minuteproject.blogspot.be/2013/08/transient-definition-as-productivity.html)
But minuteproject approach is technology agnostic so artifacts could be as well generated for other frameworks.