Rails: Render view from outside controller

前端 未结 8 2164
不思量自难忘°
不思量自难忘° 2020-12-15 03:41

I\'m trying to create an HTML string using a view. I would like to render this from a class that is not a controller. How can I use the rails rendering engine outside a co

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 03:59

    Technically, ActionMailer is a subclass implementation of AbstractController::Base. If you want to implement this functionality on your own, you'll likely want to inherit from AbstractController::Base as well.

    There is a good blog post here: https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3/ that explains the steps required.

提交回复
热议问题