I have some validation that I’m doing in a model.
As part of the error message, I would like to provide an HTML link.
What is the best approach to handling this?
APPROACH 1: One way is to
in my model so that I can use link_to to generate my link (obv. I could
hard code HTML as well).
But anyway that feels crappy - too much view stuff in the model.
APPROACH 2: A better seeming - approach would be to encapsulate the
generation of the link in a helper method and call that in my model
where I generate the error message.
How do I get access to one of my helpers from a model class?
APPROACH 3: Put in some kind of place-holder when I generate the error
in the model and then replace that on the fly in the controller before I
render the error.
Any thoughts on this?
In general, I think it’s easy to forget that when you put error message
generation in the model, you are generating view artifacts, it just may
not feel that way.