Using view helpers in Rails controllers
The other day I needed to use a view helper in my controller in order to nicely format a flash message. It turns out that it’s a simple thing to do.
In my particular case, I had a helper to format a phone number using the phony gem.
Once you have your view helper, you can use it in any rails controller by
invoking the view_context
object:
You can see more about the view_context
object in the
api dock.