How do I render a partial of a different format in Rails?

前端 未结 11 1211
执念已碎
执念已碎 2020-11-28 04:21

I\'m trying to generate a JSON response that includes some HTML. Thus, I have /app/views/foo/bar.json.erb:

{
  someKey: \'some value\',
  someH         


        
11条回答
  •  感情败类
    2020-11-28 04:58

    Beginning with Rails 3.2.3, when calling render :partial (only works outside of the respond_to block).

    render formats: [ :html ]
    

    instead of

    render format: 'html'
    

提交回复
热议问题