Rails: Render view from outside controller

前端 未结 8 2165
不思量自难忘°
不思量自难忘° 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 04:10

    Best to render the view using a controller, as that's what they're for, and then convert it to a string, as that is your ultimate goal.

    require 'open-uri'
    html = open(url, &:read)
    

提交回复
热议问题