응용 프로그램에 대한 테스트를 작성하기 시작했으며 테스트 환경을 작동하는 데 문제가 있습니다. 내 시스템에 파일 업로드를위한 종이 클립이 있으며 서버를 시작하거나 새로운 회사 레코드를 초기화하려는 시도가있을 때 트립됩니다. 예 :테스트 환경 - Paperclip의 오류
# Company.rb line 3
has_attached_file :photo,
:styles => {:medium => "200x300>", :thumb => "100x150>" },
:storage => :s3,
:s3_credentials => "#{::Rails.root.to_s}/config/s3.yml",
:path => "/photos/:style/:id/:basename.:extension"
# console
ruby-1.9.2-p0 :001 > Company.new
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]=
from /Users/san/Documents/san/app/vendor/plugins/paperclip/lib/paperclip.rb:232:in 'has_attached_file'
from /Users/san/Documents/san/app/app/models/company.rb:3:in '<class:company>'
from /Users/san/Documents/san/app/app/models/company.rb:1:in '<top (required)>'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:454:in 'load'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:454:in 'block in load_file'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in 'new_constants_in'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:453:in 'load_file'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:340:in 'require_or_load'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:491:in 'load_missing_constant'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:183:in 'block in const_missing'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:181:in 'each'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:181:in 'const_missing'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in 'const_missing_from_s3_library'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in 'const_missing'
from (irb):1
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in 'start'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:8:in 'start'
from /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:23:in '<top (required)>'
from script/rails:6:in 'require'
이 충돌의 원인과 해결 방법을 알고 있습니까?
나는 종이 클립 문서를 읽고 내가 추가 할 필요를 발견 : spec_helper.rb
에
require 'paperclip/matchers'
Spec::Runner.configure do |config|
config.include Paperclip::Shoulda::Matchers
end
합니다. 여전히 같은 오류가 발생합니다!
회사 모델의 10 번째 라인은 무엇입니까? –
'has_attached_file : photo' 줄입니다. – sscirrus
@RyanBigg - 더 많은 파고를하고 있으며 Rspec보다 더 광범위하다는 것을 알고 있습니다. 테스트 콘솔에서'Employee.new'와 같은 간단한 것을 실행할 때도 동일한 오류가 발생합니다 (''nil. [] ='을 평가하고 Employee의 첫 번째 첨부 파일을 가리킴). – sscirrus