Rails Rendering a partial within JSON

前端 未结 3 536
挽巷
挽巷 2021-01-26 12:37

I am trying to render a partial inside a JSON file so that I can use it via AJAX. Currently in my JSON file I have:

<% self.formats = [\"html\"]%>
{
   \"h         


        
3条回答
  •  庸人自扰
    2021-01-26 13:18

    You can't call to_json on a partial... it's a method of ActiveRecord. If you want json there, then it should be inside the partial.

提交回复
热议问题