Ruby on rails Rails活动存储,连接多个\u时更新映像
我在后端使用RAISAPI,在前端使用react 我使用rails活动存储来处理图像 在我的rails应用程序中,我有模式名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
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