Tuesday, June 14, 2011

Generate rails from a ERD ?

This isn't much of a blog post, it's a question !  I love ERDs (Entity Relationship Diagrams)  for database design and have been known to produce them before the database or the code .  Recently I've been doing a lot of work in Ruby on Rails which generates the database and model code for you, hiding the database under a ORM layer.  This is all very well and good  but you can see my problem.  No longer can I build  a ERD, check it's normalisation  nd optimise it with a bit of de-normalisation.

So, the question is:

Is there a tool out there that will take a ERD and generate the rails commands to build a app from the ERD.  I mean create the models and generate the migrations at least  ?

Suppose you had an ERD like this:


When I want to generate rails this would do something like the following

rails generate scaffold Person name:string
rails generate scaffold Town name:string<
rake db:migrate

It would then go in and alter the model for Person to set up the relationship to town.


Answers on a postcard !

13 comments:

  1. I've been wondering this for a while too... they have reverse ones that will build the erd from schema.rb. I prefer building the ERD before the app so I can think about how the data will flow. But I can't seem to find a tool to do this.

    ReplyDelete
  2. looks like I found something... it will generate a rails migration from an erd... http://www.malcolmhardie.com/sqleditor/ If you go to file and save you can pick 'rails' as an option

    ReplyDelete
  3. Hi Will, thats a handy tool, but ! I'd like it to generate the models as well so as to catch the releationships (such as belongs_to and has_one etc). Hmmm

    ReplyDelete
  4. I am really not sure about any tool for this so far. We generally do it manually on papers. I love ERDs too, but it usually a big mesh to handle. Thanks to Will for the help. This will help us from now.

    Roy
    SEO Philadelphia

    ReplyDelete
  5. Hey nice post. Thanks for sharing this great post with us. It is truly very interesting post.
    Magento Development

    ReplyDelete
  6. Really this is very good blog thanks for the time you took in writing this post.I would like to come on this blog again and again.
    Hire website developers

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. hmm this site is really cool and full of informative stuff.

    Application Developer Facebook

    ReplyDelete
  9. Wow really your post was very nice..explain the real practices as very clear...Thank you..
    Web Design

    ReplyDelete
  10. i Actually dont no much about ERD tool.We work on Ruby on Rails

    If we would help you in any way Contact Us @ http://www.rizecorp.com

    Ruby on Rails | Ruby on Rails Development | Rails Development

    ReplyDelete
  11. Wonderful information. I will go to share this to my friends...

    ROR Development | Ruby on Rails Development

    ReplyDelete