【问题标题】:undefined method "has_attached_file" with paperclip带有回形针的未定义方法“has_attached_file”
【发布时间】:2011-07-09 21:50:15
【问题描述】:

在从 Rails 2.3.11 升级到 3.1 时,我的应用程序出现了一些意外行为,尤其是与 Paperclip 相关的情况。

我已将 gem 'paperclip' 添加到我的 Gemfile 中,我运行了 bundle install 并且一切似乎都很顺利,除了当我启动我的服务器时,我得到了这个堆栈跟踪

...: `method_missing': undefined local variable or method `has_attached_file' for #<Class:0x7f30b32c1f88> (NameError)
...
...
from /home/user/railscamp/app/app/models/organization.rb:76
...
from /home/user/railscamp/app/config.ru:1:in `new'
from /home/user/railscamp/app/config.ru:1

有什么想法吗?

【问题讨论】:

  • 安装到根目录是什么意思?
  • 其实我想通了安装目录的事情。我犯了运行bundle install paperclip 的错误,认为它可能会做它应该做的事情,但是相反,每次我运行捆绑安装时,它都会将所有内容安装到应用程序内的“回形针/”目录中(带/或不带/不带回形针)选项)。所以我想通了并修复了它。但是,该应用似乎仍然忽略了已安装回形针这一事实。

标签: ruby-on-rails-3 paperclip ruby-1.8


【解决方案1】:

将这些添加到您的模型中

attr_accessor :image_file_name, :image_content_type, :image_file_size, :image_updated_at

【讨论】:

  • 呵呵,我其实有一个不同的问题,但看到你的评论让我意识到我还忘记了什么。谢谢
猜你喜欢
  • 2018-08-26
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-07
  • 1970-01-01
相关资源
最近更新 更多