I have a database which is postgis enabled which has some records (in a given table, there are many) that have enormous :spatial
column values.
I often use the awesome_print
gem to view records quickly while working. It colorizes and nicely displays a given record (or records') information for quick review. The problem in this case is that 99% of the terminal display is devoting to showing these spatial column's multi-page length list of coordinates in the WKT format.
I'd like for activerecord to not return these objects when viewing these with the ap
(awesome print) command. Is there any way to do that without breaking something else? Can I just instruct ActiveRecord to hide these column's values unless specifically requested or is that too much to ask?
One way or another you need to designate which fields to print, or not to print. For instance you could define a helper for this and put it, say, in the your console config file, e.g.:
def ap_article(article, cols=%w[col1 col2 col3])
ap article.attributes.slice(*cols)
end
or perhaps something like this if you just want to ignore the spatial columns
def ap_article(article)
cols = article.class.columns.select {|c| c.type != :spatial}.map(&:name)
ap article.attributes.slice(*cols)
end