Skip to content

Commit

Permalink
Add table schema information to Model#show.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdabbs committed Jan 13, 2013
1 parent 6b3c5d6 commit cf189b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/kepler/model.rb
Expand Up @@ -13,5 +13,11 @@ def sources
end
files.grep /\/app\//
end

def table
__getobj__.inspect =~ /\((.*)\)/
pairs = $1.split(',').map { |s| s.strip.split(': ') }
Hash[ pairs ]
end
end
end
8 changes: 8 additions & 0 deletions app/views/kepler/models/show.html.haml
Expand Up @@ -10,6 +10,14 @@
through
= class_link assoc.through_reflection.klass

%h4 Schema
%table
%tbody
- @model.table.each do |name, type|
%tr
%td= name
%td= type

%h4= pluralize(@model.sources.length, 'Source')
- @model.sources.each do |path|
= path
Expand Down

0 comments on commit cf189b9

Please sign in to comment.