Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2009 22:06
Show Gist options
  • Save anonymous/113784 to your computer and use it in GitHub Desktop.
Save anonymous/113784 to your computer and use it in GitHub Desktop.
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