所以我遇到了一个问题,我希望将部分保存为html字符串并使用该字符串渲染另一部分,但我不断收到双重渲染错误
def fruits
fruits = Fruits.all
market_html = "#{render partial: 'market', locals: {fruits: fruits}}"
render partial: 'super_market', locals {market_html: market_html}
end
答案 0 :(得分:2)
您想要render_to_string
吗?
market_html = render_to_string partial: 'market', locals: {fruits: fruits}