views:

330

answers:

2

Hello,

Is there any working automatic model generator for creating a model from existing database?

Something like symfony's task symfony doctrine:build-model. I found just Dr Nic’s magic model generator but it doesn't work with rails 2.3+. Please do not recommend Dr Nic's magic models. That's not what I want.

I don't believe that there is nothing else for such a common task.

EDIT: I don't want to generate just empty models. I want to also automatically generate associations and validations.

+2  A: 

Hey there. This is quite a simple procedure to do;

  1. Modify your_project/config/database.yml with connection params so that it connects up to your existing database.
  2. For each table you wish to turn into a model type the following:

script/generate model tablename

nickpellant
be careful of one thing:If your table name is 'items', camelcase and singularize it to 'Item' when running the script/generate command.another eg: 'new_users' => 'NewUser'
Good point- forgot to mention that!
nickpellant
Thanks for response. But this is not what I want. This doesn't do the same as I mentioned. If I use this, it will generate just empty model. I want something that will automatically generate associations and validations, because the information about it is there, in the database. Like "Dr Nic’s magic model generator" (wich, as I said, is not working for rails 2.3+)
Sergey
A: 

Hi,

I'd also like to see this one answered :) like all our prayers...

anybody got anything around this ?

regards raghav..

raghav