Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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 如何在另一个型号中重复使用Spree图像上传系统?_Ruby On Rails_Ruby_Ruby On Rails 4_Spree_Solidus - Fatal编程技术网

Ruby on rails 如何在另一个型号中重复使用Spree图像上传系统?

Ruby on rails 如何在另一个型号中重复使用Spree图像上传系统?,ruby-on-rails,ruby,ruby-on-rails-4,spree,solidus,Ruby On Rails,Ruby,Ruby On Rails 4,Spree,Solidus,我正在学习RubyonRails(版本4.2)。 我正在做一个疯狂的网络商务。 我必须做一个灵感页面,其中将包含描述(全球化系统),视频链接,发布和多个图像。 我不会使用回形针/卡里尔波纹宝石或其他宝石 我想使用spree产品图片上传系统。我制作了一个灵感模型和灵感图片模型 灵感.rb class Inspiration < ActiveRecord::Base validates :video_link, presence: true # validation for video a

我正在学习RubyonRails(版本4.2)。 我正在做一个疯狂的网络商务。 我必须做一个灵感页面,其中将包含描述(全球化系统),视频链接,发布和多个图像。 我不会使用回形针/卡里尔波纹宝石或其他宝石

我想使用spree产品图片上传系统。我制作了一个灵感模型和灵感图片模型

灵感.rb

class Inspiration < ActiveRecord::Base
  validates :video_link, presence: true # validation for video attributes
  # attributes for description field with globalize
  translates :description
  globalize_accessors locales: [:en, :de, :fr], attributes: [:description]
# iamges
  has_many :images, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: "Spree::Image"

  # scopes for inspiration
  scope :publishable, -> { where('published_on <= ?', Time.zone.today) }
end
类灵感{order(:position)},as::viewable,dependent::destroy,类名:“Spree::Image”
#灵感的范围

范围:可发布,->{where('published_on)您可以使用普通
创建
上传新图像,并确保您允许图像参数。我想使用spree图像模型将我所有的灵感图像存储在spree assets表中。@Engr.TanbirHasan您回答过这个问题吗?我想知道答案。干杯。
class InspirationImage < ActiveRecord::Base
  belongs_to :inspiration
end