【问题标题】:Rails plugin/engine can not load paperclipRails 插件/引擎无法加载回形针
【发布时间】:2017-05-08 17:54:54
【问题描述】:

我正在开发一个 Rails 插件。我在 gemspec 文件中有回形针:

spec.add_dependency 'paperclip', '~> 5.1'

安装gems后(使用bundle install),显示插件中安装了回形针gem。

app/models/my_plugin/class_with_data_file_entity中添加has_attached_file后:

class ClassWithDataFileEntity < ActiveRecord::Base
  has_attached_file :file, url: "/:class/:attachment/:id_partition/:filename",
end

我看到以下错误:

undefined method `has_attached_file' for #<Class:0x0000000354e7e8>

所以,插件找不到回形针。为什么会这样?回形针可以在rails插件中使用吗

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 paperclip


    【解决方案1】:

    得到了答案 - Rails Engine - Gems dependencies, how to load them into the application?

    你必须在你的 engine.rb 中要求“回形针”

    【讨论】:

      猜你喜欢
      • 2010-12-31
      • 1970-01-01
      • 2019-03-14
      • 2011-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      相关资源
      最近更新 更多