我想查询将我的food_post图片移动到image_gallery并删除food_post图片

时间:2019-07-01 11:45:47

标签: ruby-on-rails

我有image_gallery.rb根据其类型存储图像,并且图库具有与food_post.rb的多态关联,在food_post.rb内部,我还有其他用于食物张贴的图像,但我希望进行迁移,并将其也移至image_gallery并删除该图像列。

这是我的

Food_post.rb

class FoodPost < ApplicationRecord
  mount_uploader :image, ImageUploader
  mount_uploader :voice_tag, AudioUploader

  belongs_to :user
  has_many   :solera_activities, as: :activityable
  has_one    :image_gallery,     as: :imageable

  scope :posts_by_date_range, lambda { |start_date, end_date|
    start_date ||= 31.days.ago.beginning_of_day
    end_date   ||= Date.today.end_of_day
    where(created_at: start_date..end_date)
  }
end

image_gallery.rb

class ImageGallery < ApplicationRecord
  belongs_to :imageable, polymorphic: true
  mount_uploader :image, ImageUploader
end

我已经生成了一个名为“将food_post的图像移动到image_gallery并删除food_post列”的模型,我想要对此进行查询

0 个答案:

没有答案