2014-12-13 4 views
2

목표 => 여러 파일 업 로더가 작동 중입니다.Carrierwave - 정의되지 않은 메소드`mount_uploaders '

업 로더를 탑재하려고하면 다음 오류가 발생합니다. 내가 업 로더의 끝에있는 s을 제거하면

[email protected] (Message)> mount_uploaders :attachments, AttachmentUploader 
NoMethodError: undefined method `mount_uploaders' for #<Class:0x007fc17b4cc658> 
from /Users/mm/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.7/lib/active_record/dynamic_matchers.rb:26:in `method_missing' 

내가 얻을 :

[email protected] (Message)> mount_uploader :attachments, AttachmentUploader 
=> :serializable_hash 

내가 클래스가 정확한지 확인해야합니다 생각이 기준으로합니다.

[email protected] (Message)> AttachmentUploader 
=> AttachmentUploader < CarrierWave::Uploader::Base 

내 모델은 다음과 같습니다 :

class Message < ActiveRecord::Base 
    belongs_to :user 
    belongs_to :conversation 
    delegate :list, to: :conversation, allow_nil: true 
    mount_uploaders :attachments, AttachmentUploader 
end 

AttachmentUploader 클래스는 다음과 같습니다

class AttachmentUploader < CarrierWave::Uploader::Base 
    storage :file 
end 

messages 테이블은 데이터베이스에서 :

create_table "messages", force: true do |t| 
    t.integer "user_id" 
    t.integer "conversation_id" 
    t.datetime "created_at" 
    t.datetime "updated_at" 
    t.text  "payload" 
    t.hstore "headers",   default: {}, null: false 
    t.hstore "to",    default: [],    array: true 
    t.hstore "from",   default: {}, null: false 
    t.string "subject" 
    t.hstore "cc",    default: [],    array: true 
    t.text  "body" 
    t.text  "raw_body" 
    t.text  "raw_html" 
    t.json  "attachments" 
end 
이것은 내가 할 수있는 것입니다

자료 여기에 따라, README의 지시에 따랐다로 개발이 나는 이유가로드되지 않습니다 볼 수 없습니다 - 여기 https://github.com/carrierwaveuploader/carrierwave#multiple-file-uploads

것은 내가 RSpec을 시작하면 전체 스택 트레이스입니다 :

➜ GroupMailer git:(add_attachments) ✗ rspec 
Coverage report generated for RSpec to /Users/matthewbarram/projects/GroupMailer/coverage. 48/100 LOC (48.0%) covered. 
/Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activerecord-4.1.7/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `mount_uploaders' for #<Class:0x007f9269adfae0> (NoMethodError) 
    from /Users/matthewbarram/projects/GroupMailer/app/models/message.rb:5:in `<class:Message>' 
    from /Users/matthewbarram/projects/GroupMailer/app/models/message.rb:1:in `<top (required)>' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `block in require' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:348:in `require_or_load' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:480:in `load_missing_constant' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:180:in `const_missing' 
    from /Users/matthewbarram/projects/GroupMailer/spec/models/message_spec.rb:3:in `<top (required)>' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `block in load' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/bin/rspec:23:in `load' 
    from /Users/matthewbarram/.rbenv/versions/2.1.3/bin/rspec:23:in `<main>' 

어떤 도움 놀랄 것입니다! 나는 이것에 몇 시간 동안 붙어 있었다. :-)

고마워요!

답변

8

보석에 그 방법이 존재하지 않았다는 것이 밝혀졌습니다.

나는 성공적으로 보석을 다시 설치했다. 그런 다음 수동으로 github 마스터 분기를 참조하고 다시 설치하여 작동했습니다.

+0

이 솔루션을 공유해 주셔서 감사합니다.ツ –

+0

나는 고마워해야한다. 정말 저에게 시간을 절약 해주었습니다. – Marwan

0

here과 같이 수동으로 확장해야한다고 생각합니다. 해볼 수 있니?

+0

많은 행운이없는 모델에서 필요했습니다. 내가 그것을 포함시킬 수 있다고 생각하는 곳은 어디입니까? –

+0

성공하지 않고 이것을 구현하려고했습니다. https://github.com/carrierwaveuploader/carrierwave/issues/1103에는 레일이 필요없는 메모가 있습니다. 하지만 행운을 빌리지 않고'environemnts.rb' 파일과'application.rb' 파일에서 시도했습니다. –

관련 문제