【问题标题】:NoMethodError: undefined method `has_attached_file'NoMethodError:未定义的方法“has_attached_file”
【发布时间】:2010-04-30 10:43:28
【问题描述】:

Paperclip 在检查插件的 rails3 分支后会产生此错误。 我的 Gemfile 有以下行:

gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3'

错误信息是:

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

【问题讨论】:

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


    【解决方案1】:

    06-21-10 更新:thoughtbot 版本已修复。

    我必须在class Application &lt; Rails::Application 末尾添加Paperclip::Railtie.insert 到我的application.rb 以使其正常工作。自从官方回购工作以来,我已经删除了我的叉子。希望对某人有所帮助。

    您还需要将以下内容添加到您的 Gemfile 中

    gem "paperclip", :git => "http://github.com/thoughtbot/paperclip.git"
    

    【讨论】:

      【解决方案2】:

      我有一个回形针叉子,你可以试试它是否能在你的最后工作,只需更改你的 Gemfile:

      gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3'
      

      不要忘记在更新您的 Gemfile 后运行 bundle install。

      希望它能解决您的问题。

      lmumar

      【讨论】:

      • "评估 paperclip.gemspec 时出现 LoadError。它是否尝试要求相对路径?这在 Ruby 1.9 中不起作用。"
      • 谢谢 - 为我工作 :-) 这将让我继续前进,直到 master 为 Rails3 完全修复。
      • 这个叉子也对我有用。希望thoughtbot 很快就会从lmumar 撤出:)
      【解决方案3】:

      minter 的叉子对我有用:

      gem 'paperclip', :git => 'http://github.com/minter/paperclip.git', :branch => 'rails3'
      

      【讨论】:

        【解决方案4】:

        这对我不起作用。 我已经完成了以下事情,并且运行良好:

        • 在 application.rb 中添加“Paperclip::Railtie.insert”
        • 在 development.rb 中添加“config.gem 'paperclip'”

        【讨论】:

          【解决方案5】:

          它适用于 Jason King 的回形针版本:

          gem 'paperclip', :git => 'http://github.com/JasonKing/paperclip.git', :branch => 'rails3'
          

          【讨论】:

          • 这似乎不再存在了。
          猜你喜欢
          • 1970-01-01
          • 2013-04-24
          • 2023-03-06
          • 2015-05-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多