将网址另存为Ruby on Rails postgres数据库

时间:2018-10-16 09:12:43

标签: ruby-on-rails

尝试将URL从API保存到rails。但是,URL被保存为一个数组,这不是我想要的。如何将其保存为仅字符串而不是数组。

  def create

    @listing = Listing.new(listing_params)

    galleries = params[:pictureData]

    galleries.each do |image|
      @picture = @listing.pictures.build( image: image)
    end

    if @listing.save
      render json: { status: "success", code: 200, message: "OK" }
    else
      render json: { errors: @listing.errors }, status: 500
    end
end

当我打印图像时。例如,打印时不带[“”]

https://res.cloudinary.com/tsarich/image/upload/v1539634235/user_rooms/areqtywtmuknuhetgumg.jpg

感谢您的帮助。

0 个答案:

没有答案