Reputation: 4213
Part of my app is accessible to me alone when I login as admin.
In documents#new
and documents#edit
, I have a <textarea>
in a form which I use to write and edit structured text using HAML.
I display the structured text in documents#show
and documents#print
via:
- engine = Haml::Engine.new(@document.content)
= engine.render
On localhost:3000
, if I make an error in my HAML -- such as indenting with the wrong number of spaces -- I see the error in the browser.
In production on Heroku, this is disabled for security reasons, which is what you'd want.
But I still want to see this particular error in production, as it's actually just a typo in my text, not a vulnerability in my app. Is there some way I can send this HAML rendering error to the browser?
I'm thinking the answer might look something like the following, but I'm not sure what.
- begin
- engine = Haml::Engine.new(@document.content)
= engine.render
- rescue
- return ##something??##
- end
Even better of course would be to find a way to shove that into a model-level validation.
Upvotes: 1
Views: 1272
Reputation: 4213
Answer was:
-begin
- engine = Haml::Engine.new(@document.content)
= engine.render
- rescue => e
= e.message
Upvotes: 4