Ruby on rails 意外'<';使用邮递员和rails时post出错

Ruby on rails 意外'<';使用邮递员和rails时post出错,ruby-on-rails,json,postman,Ruby On Rails,Json,Postman,我要填充的JSON响应如下所示: { "vendor": { "name": "Mozelle Luettgen MD", "email": "tyqmn@example.net", "phone_no": "9999997660", "addressline1": "Kulas Stravenue", "addressline2": "64636 Lynch Springs", "landmark": "Apt. 14

我要填充的JSON响应如下所示:

{
    "vendor":
    {
     "name": "Mozelle Luettgen MD",
     "email": "tyqmn@example.net",
     "phone_no": "9999997660",
     "addressline1": "Kulas Stravenue",
     "addressline2": "64636 Lynch Springs",
     "landmark": "Apt. 142",
     "city": "South Hannaview",
     "state": "North Dakota",
     "country": "Palau",
     "pincode": "53912-6122",
     "latitude": 50.8247548421224,
     "longitude": -81.8429583068792,
     "status": true
    } 
 }
创建供应商的控制器代码为

  def create 
    @vendor = Vendor.new(vendor_params)
    respond_to do |format|
    if @vendor.save
      format.html { redirect_to @vendor, notice: 'Vendor was                         
      successfully created.' }
      format.json { render :show, status: :created, location: @vendor, 
      :msg => { :status => "ok" , :result => @vendor.json, :message =>  
      "Succesfully Created" }
      }
    else
     format.html { render :new }
     format.json { render json: @vendor.errors, status: 
     :unprocessable_entity, 
     :msg =>
     { :status => "Error", :message =>  "Unprocessable Entity" }
     }
   end
  end
end


  def vendor_params
  params.require(:vendor).permit(:name, :email, :phone_no,
     :addressline1, :addressline2, :landmark, 
    :city, :state, :country, :pincode, :latitude, :longitude, :status, 
    {products_attributes: [:id, :product_name, :price]},
    {vendor_products_attributes: [:id, :vendor_product_id, :vendor_id,             
   :product_id, :copies, :_destroy]})
end

使用post运行此链接时,状态显示为200 ok,但当我查找JSON响应时,对于创建的供应商,它会抛出意外的“,原因是您可能在尝试连接到postman时登录到另一个浏览器或其他地方打开了会话。这就是您得到“意外'>'的原因”


为了避免这种情况,请使用登录api登录到postman并尝试点击您的服务。它肯定会起作用。

我也遇到了同样的问题,并且能够通过更改同步链接对其进行排序

确保您没有两次声明此var
User=require(“../Models/User”)route/user.js
和main
server/app.js文件中的模型类的code>object


您在模型类中声明了两次对象,postman应用程序中的此设置帮助我解决了此问题

全局代理配置:打开

代理类型:HTTPS

代理服务器:abc.xyz.abc.com:8080


使用系统代理:关闭

是否使用调试器进行检查,你在控制器上得到了什么参数?我已经更新了显示允许的参数的问题。我认为@power要求调试器查看当你在Postman中运行事务时控制器中实际存在的参数。哦,对了@power…在binding.pry上检查参数,我得到了以下参数:{“vendor”=>{“姓名”=>“Mozelle Luettgen MD”,“电子邮件”=>”ajczzz@example.net“,”电话号码“=>”999997660“,”地址线1“=>”库拉斯斯特拉维内“,”地址线2“=>”64636林奇泉“,”地标“=>”142公寓“,”城市“=>”南汉纳维“,”州“=>”北达科他州“,”国家“,”帕劳“,”平码“=>”53912-6122“,”纬度“=>50.8247548421224,”经度“=>-81.8429583068792,“状态”=>true},“控制器”=>“供应商”,“操作”=>“创建”}。这就是您想要的吗?如果编辑JSON返回结构并将
位置:@vendor
更改为
:位置=>@vendor.id
,会发生什么?