回形针Ruby on Rails 4安装错误?

时间:2014-05-13 20:40:16

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

添加gem和bundle安装后,我试图生成回形针,但是我收到错误?

在GemFile中

      gem "paperclip", "~> 4.1"

在命令行中:

 $   rails generate paperclip user avatar

我得到错误:

   /Users/amirna/.rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/generators/actions/create_migration.rb:13:in `migration_file_name': protected method `migration_file_name' called for #<PaperclipGenerator:0x007fc6c7e43690> (NoMethodError)
from /Users/amirna/.rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/generators/actions/create_migration.rb:34:in `existing_migration'
from /Users/amirna/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:112:in `invoke_with_conflict_check'
from /Users/amirna/.rvm/gems/ruby-2.1.1/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'

2 个答案:

答案 0 :(得分:6)

PaperClip - https://github.com/thoughtbot/paperclip/issues/1495

是一个记录在案的问题

将其更改为:

gem 'paperclip', github: 'thoughtbot/paperclip'

答案 1 :(得分:2)

如果生成器不起作用,您应该手动尝试迁移。或者如果上述答案没有解决它。

class AddAvatarColumnsToUsers < ActiveRecord::Migration
  def self.up
    add_attachment :users, :avatar
  end

  def self.down
    remove_attachment :users, :avatar
  end
end