Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails model generator - from existing database

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.

like image 357
Sergey Avatar asked Dec 26 '09 22:12

Sergey


1 Answers

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

like image 149
nickpellant Avatar answered Oct 09 '22 13:10

nickpellant