I have a method on an active record class that renders an ERB template for a messaging system. The simplified code looks like this:
ERB.new(template).result(binding)
where binding
is the current Binding of the ActiveRecord model object and template
is an erb template file read in from the file system.
I would like to use some named routes within the template, but haven't been able to make the named routes available.
I've seen posts all over stating to include/require various combinations of the following into the current ActiveRecord model (or preferably as a singleton):
include ActionView::Helpers::TagHelper
include ActionView::Helpers::AssetTagHelper
include ActionController::UrlWriter
require 'action_controller/routing'
include ActionController::Routing
include ActionController::Routing::Routes
include ActionController::Routing::NamedRoutes
Some of these error and I think are not correct at all...others I see no benefit from since the routes still don't work. Does anyone have an idea?