未定义的方法“has_attached_file”:ActiveAdmin 和黄瓜出现回形针错误
undefined method `has_attached_file' : Paperclip error with ActiveAdmin and cucumber
我已经安装了 ActiveAdmin(1.0.0.pre1)、Paperclip(4.2.1) 和 Cucumber(1.4.2)。
当我用黄瓜进行测试时,我的系统遇到了一个奇怪的问题。
我有一个带有回形针配置的模型,并且有方法 has_attached_file。然而一切都运行良好,但我用黄瓜进行测试它引发了关于该模型的活动管理资源的错误。
这是完整的错误堆栈:
undefined method `has_attached_file' for Document (call 'Document.connection' to establish a connection):Class (NoMethodError)
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
/home/anand/rails_workspace_20_1_2015/MyApp/app/models/document.rb:7:in `<class:Document>'
/home/anand/rails_workspace_20_1_2015/MyApp/app/models/document.rb:2:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:360:in `require_or_load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:494:in `load_missing_constant'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:184:in `const_missing'
/home/anand/rails_workspace_20_1_2015/MyApp/app/admin/document.rb:2:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:197:in `block in load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/error.rb:41:in `capture'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:197:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:189:in `block in load!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:189:in `each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:189:in `load!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:211:in `routes'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin.rb:79:in `routes'
/home/anand/rails_workspace_20_1_2015/MyApp/config/routes.rb:2:in `block in <top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:410:in `draw'
/home/anand/rails_workspace_20_1_2015/MyApp/config/routes.rb:1:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in `each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:16:in `reload!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/file_update_checker.rb:75:in `call'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/file_update_checker.rb:75:in `execute'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:27:in `updater'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:427:in `each_strongly_connected_component_from'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:345:in `each'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:345:in `call'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:205:in `tsort_each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-rails-1.4.2/lib/cucumber/rails/application.rb:15:in `initialize!'
/home/anand/rails_workspace_20_1_2015/MyApp/config/environment.rb:5:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-rails-1.4.2/lib/cucumber/rails.rb:7:in `require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-rails-1.4.2/lib/cucumber/rails.rb:7:in `<top (required)>'
/home/anand/rails_workspace_20_1_2015/MyApp/features/support/env.rb:8:in `require'
/home/anand/rails_workspace_20_1_2015/MyApp/features/support/env.rb:8:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/rb_support/rb_language.rb:95:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/rb_support/rb_language.rb:95:in `load_code_file'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:180:in `load_file'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:82:in `each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime.rb:184:in `load_step_definitions'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime.rb:42:in `run!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/cli/main.rb:47:in `execute!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/bin/cucumber:13:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/cucumber:23:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/cucumber:23:in `<main>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/ruby_executable_hooks:15:in `eval'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/ruby_executable_hooks:15:in `<main>'
宝石文件:
source 'https://rubygems.org'
gem 'devise'
gem 'mysql2'
gem 'cancancan'
gem 'activeadmin' , github: "activeadmin"
gem 'paperclip'
gem 'paper_trail'
gem 'rails', '4.2.1'
gem 'jquery-rails'
group :development, :test do
gem 'byebug'
gem 'pry-byebug'
gem 'pry-stack_explorer'
gem 'pry-rails'
gem 'pry-doc'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'factory_girl_rails'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails', require: false
gem 'rspec-rails'
end
型号:
class Document < ActiveRecord::Base
belongs_to :user
has_paper_trail
has_attached_file :doc, :default_url => "/images/:style/missing.png"
validates_attachment :doc, content_type: {:content_type => ["application/pdf", /\Aimage\/.*\Z/ ] }
end
ActiveAdmin 资源:
ActiveAdmin.register_page "Document" do
end
出现这个问题的原因是什么?我已经尝试搜索 google 中的所有资源,并可能通过其他方式来追踪它。最后我在这里发布了。需要建议。谢谢。
在查阅了所有文件和实验后,我终于找到了解决办法。问题是 Rails.root/lib
文件夹中的 paperclip.rb
文件。该文件不包含任何内容,但它在我 运行 黄瓜时产生了问题。所以我删除了那个文件,一切正常。希望这对其他人有帮助:-)
我已经安装了 ActiveAdmin(1.0.0.pre1)、Paperclip(4.2.1) 和 Cucumber(1.4.2)。
当我用黄瓜进行测试时,我的系统遇到了一个奇怪的问题。
我有一个带有回形针配置的模型,并且有方法 has_attached_file。然而一切都运行良好,但我用黄瓜进行测试它引发了关于该模型的活动管理资源的错误。
这是完整的错误堆栈:
undefined method `has_attached_file' for Document (call 'Document.connection' to establish a connection):Class (NoMethodError)
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activerecord-4.2.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
/home/anand/rails_workspace_20_1_2015/MyApp/app/models/document.rb:7:in `<class:Document>'
/home/anand/rails_workspace_20_1_2015/MyApp/app/models/document.rb:2:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:360:in `require_or_load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:494:in `load_missing_constant'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:184:in `const_missing'
/home/anand/rails_workspace_20_1_2015/MyApp/app/admin/document.rb:2:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:197:in `block in load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/error.rb:41:in `capture'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:197:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:189:in `block in load!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:189:in `each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:189:in `load!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin/application.rb:211:in `routes'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bundler/gems/activeadmin-28e8a8f36640/lib/active_admin.rb:79:in `routes'
/home/anand/rails_workspace_20_1_2015/MyApp/config/routes.rb:2:in `block in <top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:410:in `draw'
/home/anand/rails_workspace_20_1_2015/MyApp/config/routes.rb:1:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in `each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:16:in `reload!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/file_update_checker.rb:75:in `call'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/activesupport-4.2.1/lib/active_support/file_update_checker.rb:75:in `execute'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:27:in `updater'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:427:in `each_strongly_connected_component_from'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:345:in `each'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:345:in `call'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
/home/anand/.rvm/rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/tsort.rb:205:in `tsort_each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-rails-1.4.2/lib/cucumber/rails/application.rb:15:in `initialize!'
/home/anand/rails_workspace_20_1_2015/MyApp/config/environment.rb:5:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-rails-1.4.2/lib/cucumber/rails.rb:7:in `require'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-rails-1.4.2/lib/cucumber/rails.rb:7:in `<top (required)>'
/home/anand/rails_workspace_20_1_2015/MyApp/features/support/env.rb:8:in `require'
/home/anand/rails_workspace_20_1_2015/MyApp/features/support/env.rb:8:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/rb_support/rb_language.rb:95:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/rb_support/rb_language.rb:95:in `load_code_file'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:180:in `load_file'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:82:in `each'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime.rb:184:in `load_step_definitions'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/runtime.rb:42:in `run!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/lib/cucumber/cli/main.rb:47:in `execute!'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/gems/cucumber-1.3.19/bin/cucumber:13:in `<top (required)>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/cucumber:23:in `load'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/cucumber:23:in `<main>'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/ruby_executable_hooks:15:in `eval'
/home/anand/.rvm/gems/ruby-2.2.0-preview1/bin/ruby_executable_hooks:15:in `<main>'
宝石文件:
source 'https://rubygems.org'
gem 'devise'
gem 'mysql2'
gem 'cancancan'
gem 'activeadmin' , github: "activeadmin"
gem 'paperclip'
gem 'paper_trail'
gem 'rails', '4.2.1'
gem 'jquery-rails'
group :development, :test do
gem 'byebug'
gem 'pry-byebug'
gem 'pry-stack_explorer'
gem 'pry-rails'
gem 'pry-doc'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'factory_girl_rails'
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails', require: false
gem 'rspec-rails'
end
型号:
class Document < ActiveRecord::Base
belongs_to :user
has_paper_trail
has_attached_file :doc, :default_url => "/images/:style/missing.png"
validates_attachment :doc, content_type: {:content_type => ["application/pdf", /\Aimage\/.*\Z/ ] }
end
ActiveAdmin 资源:
ActiveAdmin.register_page "Document" do
end
出现这个问题的原因是什么?我已经尝试搜索 google 中的所有资源,并可能通过其他方式来追踪它。最后我在这里发布了。需要建议。谢谢。
在查阅了所有文件和实验后,我终于找到了解决办法。问题是 Rails.root/lib
文件夹中的 paperclip.rb
文件。该文件不包含任何内容,但它在我 运行 黄瓜时产生了问题。所以我删除了那个文件,一切正常。希望这对其他人有帮助:-)