Is there a good tool to generate an image of the database schema used in a Rails app?
views:
204answers:
4Have you tried rake db:schema:dump?
Essentially, make sure that your database.yml
file is referencing the database you wish to dump, and then run the command. It'll take all of the tables and indexes in said database and then write it out to schema.rb
.
Note that you should rename schema.rb
once it contains the dump; otherwise, it could it overwritten.
If by "image" you mean a graphical representation of your tables and their relationships, then the answer relates not so much to Rails (unless you examined the models for the declared associations) but to the database generally.
Question 30474 addressed that - see if any of the suggestions help, although without foreign key constraints defined in the database there may be a fair amount of manual work to do...
I have been using RailRoad to generate diagrams of my applications.
There are diagrams for both Models and Controllers.
http://railroad.rubyforge.org/
This is the introduction from the website:
RailRoad is a class diagrams generator for Ruby on Rails applications. It's a Ruby script that loads the application classes and analyzes its properties (attributes, methods) and relationships (inheritance, model associations like has_many, etc.) The output is a graph description in the DOT language, suitable to be handled with tools like Graphviz.
RailRoad can produce:
- Model diagrams, showing both inheritance hierarchy and models associations. You can choose to show the model "content columns" and its types.
- Controller diagrams, showing inheritance hierarchy. You can include the controllers' methods, grouped by its visibility (public, protected, private.)
- State machine diagramas (for use with the "acts_as_state_machine" plugin.)