我想渲染我的模板,并在应用程序的某些操作中将html / json保存在变量中。就像是:
def show
@var = Var.find(params[:id])
x = render "tmeplate1", format: :json
render nothing: true
end
当我调用此操作时,出现错误: AbstractController::DoubleRenderError in VarsController#show
还有其他方法可以使用模板而不进行两次渲染吗?
你写呈现在为什么双渲染错误出现的方法两次。使用render_to_string
x = render_to_string "tmeplate1", format: :json
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句