我有一个 Rails 应用程序,它以 json 格式显示嵌套表单。
在 JSON 响应中,我还显示了一个代表另一个表的 id 字段。
如何显示与我得到的那个 id 对应的名称,以便我可以以我的 json 格式显示名称和 id。
我的控制器显示方法
def show
@maintemplate = Maintemplate.find(params[:id])
respond_with (@maintemplate) do |format|
format.json { render :json => @maintemplate }
end
end
提前致谢....