Created
May 18, 2009 22:06
-
-
Save anonymous/113784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def model_for_table(table_name) | |
table_name.classify.constantize | |
end | |
def index | |
schemas = Hash.new | |
ActiveRecord::Base.connection.tables.each do |table| | |
if table != "schema_migrations" | |
model = model_for_table(table) | |
columns = Array.new | |
model.columns.each do |column| | |
columns.push({"name" => column.name, "type" => column.type}); | |
end | |
schemas[model.table_name] = columns; | |
end | |
end | |
respond_to do |format| | |
format.any { render :json => schemas } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment