【问题标题】:How can I create some Paperclip objects from a Rake task?如何从 Rake 任务创建一些 Paperclip 对象?
【发布时间】:2012-01-03 00:55:08
【问题描述】:

我有一个模型Idea,其中has_attached_file :file1has_attached_file :file2。出于开发目的,我有一个“引导”任务,它负责创建一些初始对象(这样您就不必创建用户,然后每次我们删除 sqlite 文件时上传一些文件)。我应该如何从 Rake 任务中执行此操作?

【问题讨论】:

    标签: ruby-on-rails ruby paperclip


    【解决方案1】:

    试试:

    Idea.new(
      :name => 'bla',
      :file1 => File.open('/some/path/to.file'),
      :file2 => File.open('/some/path/to.file')
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-09
      • 2012-05-30
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 2013-09-14
      • 1970-01-01
      相关资源
      最近更新 更多