5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Rails モデル作成時 ファイルアップロードエラー

Posted at

問題

Sample.create({name: "hoge", icon: File::open('db/dummy-001.png')})

rails aborted!
Errno::EXDEV: Invalid cross-device link @ rb_file_s_link - (db/dummy-001.png, /tmp/7408f7ac8f26bae8efad1f94360df7e420200514-12545-30ex00.png)
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/io_adapters/abstract_adapter.rb:62:in `link_or_copy_file'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/io_adapters/abstract_adapter.rb:55:in `copy_to_tempfile'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/io_adapters/file_adapter.rb:21:in `cache_current_values'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/io_adapters/file_adapter.rb:11:in `initialize'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/io_adapters/registry.rb:33:in `new'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/io_adapters/registry.rb:33:in `for'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/attachment.rb:100:in `assign'
/work/vendor/bundle/ruby/2.4.0/gems/paperclip-6.1.0/lib/paperclip/has_attached_file.rb:66:in `block in define_setter'
/work/vendor/bundle/ruby/2.4.0/gems/activemodel-5.2.1/lib/active_model/attribute_assignment.rb:51:in `public_send'
/work/vendor/bundle/ruby/2.4.0/gems/activemodel-5.2.1/lib/active_model/attribute_assignment.rb:51:in `_assign_attribute'
/work/vendor/bundle/ruby/2.4.0/gems/activemodel-5.2.1/lib/active_model/attribute_assignment.rb:44:in `block in _assign_attributes'
/work/vendor/bundle/ruby/2.4.0/gems/activemodel-5.2.1/lib/active_model/attribute_assignment.rb:43:in `each'
/work/vendor/bundle/ruby/2.4.0/gems/activemodel-5.2.1/lib/active_model/attribute_assignment.rb:43:in `_assign_attributes'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/attribute_assignment.rb:23:in `_assign_attributes'
/work/vendor/bundle/ruby/2.4.0/gems/activemodel-5.2.1/lib/active_model/attribute_assignment.rb:35:in `assign_attributes'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/core.rb:314:in `initialize'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/inheritance.rb:66:in `new'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/inheritance.rb:66:in `new'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/persistence.rb:35:in `create'
/work/db/seeds.rb:41:in `block in <main>'
/work/db/seeds.rb:41:in `map'
/work/db/seeds.rb:41:in `<main>'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
/work/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:281:in `block in load'
/work/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
/work/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:281:in `load'
/work/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/engine.rb:551:in `load_seed'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/tasks/database_tasks.rb:281:in `load_seed'
/work/vendor/bundle/ruby/2.4.0/gems/activerecord-5.2.1/lib/active_record/railties/databases.rake:194:in `block (2 levels) in <main>'
/work/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/work/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/work/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/command.rb:48:in `invoke'
/work/vendor/bundle/ruby/2.4.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<main>'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/work/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/work/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
/work/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
/work/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
bin/rails:4:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
make: *** [seed] Error 1

解決

vendor 配下が何らかの理由で壊れていたようです...。

$ rm -rf vendor/
$ bundle install --path vendor/bundle
5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?