Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails活动存储,连接多个\u时更新映像_Ruby On Rails_Rails Activestorage - Fatal编程技术网

Ruby on rails Rails活动存储,连接多个\u时更新映像

Ruby on rails Rails活动存储,连接多个\u时更新映像,ruby-on-rails,rails-activestorage,Ruby On Rails,Rails Activestorage,我在后端使用RAISAPI,在前端使用react 我使用rails活动存储来处理图像 在我的rails应用程序中,我有模式名Post class Post < ApplicationRecord has_many_attached :pictures def picture_url if self.pictures.attached? self.pictures.map do |picture| Rails.application.routes

我在后端使用RAISAPI,在前端使用react

我使用rails活动存储来处理图像

在我的rails应用程序中,我有模式名
Post

class Post < ApplicationRecord
  has_many_attached :pictures

  def picture_url
    if self.pictures.attached?
      self.pictures.map do |picture|
        Rails.application.routes.url_helpers.rails_blob_path(picture, 
        only_path: true)
      end
    else
      nil
    end
  end
end
  def update
    post = Post.find(params[:id])
    if post.update_attributes(message: params[:message], picture: 
       params[:picture])
      render_success(:ok, post, meta: { message: 'Post updated' })
    else
      render_error(422, post.errors, message: 'Failed to update post')
    end
  end