2011-08-25 5 views
1

응용 프로그램에 대한 테스트를 작성하기 시작했으며 테스트 환경을 작동하는 데 문제가 있습니다. 내 시스템에 파일 업로드를위한 종이 클립이 있으며 서버를 시작하거나 새로운 회사 레코드를 초기화하려는 시도가있을 때 트립됩니다. 예 :테스트 환경 - 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 

합니다. 여전히 같은 오류가 발생합니다!

+0

회사 모델의 10 번째 라인은 무엇입니까? –

+0

'has_attached_file : photo' 줄입니다. – sscirrus

+0

@RyanBigg - 더 많은 파고를하고 있으며 Rspec보다 더 광범위하다는 것을 알고 있습니다. 테스트 콘솔에서'Employee.new'와 같은 간단한 것을 실행할 때도 동일한 오류가 발생합니다 (''nil. [] ='을 평가하고 Employee의 첫 번째 첨부 파일을 가리킴). – sscirrus

답변

0

결국 오류는 Paperclip을 2.3.6으로 다운 그레이드하여 해결되었습니다. 이는 제가 일주일 전까지 사용하고 있던 것입니다. 희망적으로 이것은 미래에이 오류가 발생하는 사람들에게 도움이 될 것입니다!

0

s3.yml에는 현재 Rails 환경의 키가 포함되어 있지 않습니다 (아마도 test)? 하나 추가하십시오. 그걸 고쳐야 해!

+0

S3 버킷 이름, access_key 및 secret_access_key를 확인했는데 모든 것이 체크 아웃 된 것처럼 보입니다. 다른 뭔가가 될 수 있을까요? – sscirrus