我有home_controller
并且里面有[:index, :process_img]
动作。 我需要从行动:process_img
获得整个html源:index
行动。需要访问控制器中的代码。在控制器中获取erb模板的html代码
class HomeController < ActionController::Base
def index
end
def process_img
index_html_code = "the html source of index action should be here"
end
end
我该如何做到这一点?提前致谢!
你可以尝试'render_to_string'? https://apidock.com/rails/ActionController/Base/render_to_string –
@AjinkyaPisal没有帮助不会导致我得到Missing模板错误,但我有我的应用程序中的模板。 –
@AjinkyaPisal修复了现在的问题!谢谢! –