如何在rails json响应中合并图像url?

时间:2015-12-07 13:56:22

标签: ruby-on-rails json rails-api

我想发送@survey image_url及其属性。如何发送

@survey_detail = @survey.as_json(:include => { :questions => { :include => { :options => {:only => :title } } } })
render json: {:success=>true, :message=>"Detail of survey",:survey=>@survey_detail}, :status=>200

除了@survey我要发送的其他属性@ survey.image.url。我想将其与其他调查属性合并。

我知道吗?

1 个答案:

答案 0 :(得分:0)

您可以发送所需的属性数量。只需像这样添加它们:

render :json => {:success => true, :message=>'Your message', locals => {:survey =>@survey_detail, ....here you an add what attributes you want to send... }