转换它的最佳方式是:id变量
@object = Object.find(params[:id])
成一个字符串?
render :json => {"status" => "404", "message" => "Object with id " + ":id" + " not found"}
也尝试过:
render :json => {"status" => "404", "message" => "Object with id #{:id} not found"}
但它给出了这个错误:
没有将符号隐式转换为字符串
答案 0 :(得分:3)
只需将#{:id}
替换为"#{params[:id]}"