I'm storing Ruby code in a database so that if an administrator needs to tweak the code logic, they use ActiveAdmin to make edits. My app is written in such a way to load & call this code from the database.
My problem now is that the text rendered in the ActiveAdmin UI show page is not very readable code because it is not monospaced or syntax highlighted. How can I apply syntax highlighting to this particular row?
Would you use the Rouge gem? If so, can you wrap your code or do you need to monkey-patch ActiveAdmin? What other solutions exist?
ActiveAdmin.register Model do
show do |model|
attributes_table do
row :name
row :logic # render this logic text as Ruby code
row :created_at
row :updated_at
end
end
end
You should be able to use the Arbe syntax to wrap it in a
pre
orcode
tag:You could also use the
code
tag instead ofpre
, they're just slightly different. Either way any more serious customization should be done with CSS.Original Poster's Note: wrap the
code
block withpre
if using highlight.js.