Reputation: 2197
I'm looking for a way to inspect a database schema and auto-generate models in Rails. Does anyone know of a project/gem that does this?
Upvotes: 0
Views: 52
Reputation: 8898
Active Record is good for this. If you want to use it outside rails, then
class Foo < ActiveRecord::Base
# In case the table name not following rails convention
self.table_name = 'bar'
end
db_config = {
adapter: 'mysql2',
host: 'localhost',
port: 3306,
database: 'foobar'
}
ActiveRecord::Base.establish_connection(db_config)
That's all.
Upvotes: 1