I am trying to eval a routing helper string in a class that is designed for unsafe code evaluation. Basically I have a class SafeEval which will evaluate string in a sandboxed class. I did following to get route helpers working in SafeEval
include ActionController::UrlFor
include Rails.application.routes.url_helpers
All ruote helpers are working except engine route proxies. In my views and controllers I can call blog.page_path(@page) but I can't call blog.page_path in SafeEval - I get blog not defined. I checked in my view and blog is RouteProxy.
So my question is how can I get engine route proxy in a class outside view/controller
(SafeEvla does not do a lot of sandboxing. you can assume very simple structure: a method that just runs eval(str) for now inside a SafeEval class.)
I think including the mounted helpers in your class would solve the problem:
include Rails.application.routes.mounted_helpers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With