It is a documented issue at PaperClip
- https://github.com/thoughtbot/paperclip/issues/1495
Change that to :
gem 'paperclip', github: 'thoughtbot/paperclip'
質問
after adding gem and bundle install, I tried to generate paperclip but I get error?
In GemFile
gem "paperclip", "~> 4.1"
In command line:
$ rails generate paperclip user avatar
Error I get:
/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!'
解決
It is a documented issue at PaperClip
- https://github.com/thoughtbot/paperclip/issues/1495
Change that to :
gem 'paperclip', github: 'thoughtbot/paperclip'
他のヒント
You should try the migration manually if the generator doesn't work. Or if the above answer doesn't fix it.
class AddAvatarColumnsToUsers < ActiveRecord::Migration
def self.up
add_attachment :users, :avatar
end
def self.down
remove_attachment :users, :avatar
end
end