How can you start a rails project on top of a large legacy database … use the legacy_data plugin.
What if the database doesn't follow Rails/ActiveRecord naming conventions? … not a problem What if there are a lot of tables? … not a problem What about all the information contained in the database already (relationships, constraints, etc) … they are extracted into your models
Usage: script/generate models_from_tables [options]
--table-name [ARG] Only generate models for tables starting with --table-naming-convention [ARG] Naming convention for tables in the database. Only the wildcard is used when generating the model name
script/generate script/generate models_from_tables –table-naming-convention=tb* Generate a model for each table in the database. The tables all start with a tb (i.e. table 'tbperson' will generate the model 'person')
script/generate script/generate models_from_tables –table-name tbperson Generate a model for the 'tbperson' table in the database.
Create a new rails project with the admin data plugin rails my_application -m gist.github.com/188172.txt
Configure your application to connect to your existing Oracle database. Get the connect connect string from your dba (something like: email@example.com:1541/sid.world) and edit your config/database.yml
adapter: oracle_enhanced database: server.example.com:1541/sid.world username: user password: password
Generate models for all existing tables script/generate models_for_all
Take a look script/server localhost:3000/admin_data
Note on Patches/Pull Requests
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so I don't break it in a future version unintentionally.
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but
bump version in a commit by itself I can ignore when I pull)
Send me a pull request. Bonus points for topic branches.
Copyright © 2009 Alex Rothenberg. See LICENSE for details.