Very often I have to work on databases which do not follow ActiveRecord convention and making ActiveRecord models, if number of tables is large, is very slow and boring task. In order to speed up and simplify it I’ve created Rmre gem. Gem is quite simple yet you might find it useful if you want to create fixtures, migrations or simply port application to Ruby on Rails.
So how it works? For each table in the database, gem creates model. Name of the model is created using Rails
classify method. Moreover, if table’s primary key is not column named “id” gem sets primary key by adding
set_primary_key "primaryKeyColumnName" line to the model. In addition for MySQL, PostgreSQL, Oracle or MS SQL foreign keys are analyzed and for each constraint gem generates
has_many lines. Here is model created for table store in Sakila MySQL test database:
1 2 3 4 5 6 7 8 9