복붙노트

[RUBY-ON-RAILS] 나가서 설명하자면 NameError (초기화되지 않은 일정 종이 클립 :: 보관 :: S3 :: AWS) :

RUBY-ON-RAILS

나가서 설명하자면 NameError (초기화되지 않은 일정 종이 클립 :: 보관 :: S3 :: AWS) :

내 웹 응용 프로그램으로 이미지를 통합하기 위해 노력하고있어 나는 꽤 많은 기능을 제거한 후이 오류로 실행하십시오. 그것은 내 '생성'응용 프로그램 컨트롤러에 내려 와서 나는 완전히 확실 여기에서 어디로 가야하지 않다.

2015-02-06T20:30:12.292187+00:00 app[web.1]:    (1.9ms)  ROLLBACK
2015-02-06T20:30:12.296299+00:00 app[web.1]: NameError (uninitialized constant Paperclip::Storage::S3::AWS):
2015-02-06T20:30:12.296301+00:00 app[web.1]:   app/controllers/articles_controller.rb:24:in `create'
2015-02-06T20:45:14.691084+00:00 app[web.1]: [paperclip] saving /articles/images/000/000/013/original/git.jpeg
2015-02-06T20:45:14.698744+00:00 app[web.1]: Completed 500 Internal Server Error in 584ms
2015-02-06T20:45:14.700871+00:00 heroku[router]: at=info method=POST path="/articles" host=preston.herokuapp.com request_id=d9d02257-3616-4686-bce5-3d912cd528c2 fwd="76.22.102.38" dyno=web.1 connect=1ms service=698ms status=500 bytes=1754

Articles_controller.rb

class ArticlesController < ApplicationController
http_basic_authenticate_with name: "name", password: "password", except: [:index, :show]

    def index
        @articles = Article.all.order("created_at DESC")
    end

    def show
        @article = Article.find(params[:id])
    end

    def new
        @article = Article.new
    end 

    def edit
        @article = Article.find(params[:id])

    end

    def create
        @article = Article.new(article_params)

        if @article.save
          redirect_to @article
        else
            render 'new'
        end  
    end

    def update
        @article = Article.find(params[:id])

        if @article.update(article_params)
            redirect_to @article
        else
            render 'edit'
        end
    end

    def destroy
        @article = Article.find(params[:id])
        @article.destroy

        redirect_to articles_path
    end

    private

    def article_params
        params.require(:article).permit(:title, :text, :image)
    end
end

Gemfile

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bootstrap-sass', '~> 3.3.3' 
gem 'autoprefixer-rails'
gem 'paperclip', '~> 4.2.1'
gem 'aws-sdk', '~> 2.0.22'

group :development, :test do
 gem 'byebug'
 gem 'web-console', '~> 2.0'
 gem 'spring'
 gem 'sqlite3'
end

group :production do
    gem 'pg'
    gem 'rails_12factor'
end

group :doc do
    gem 'sdoc', '~> 0.4.0', require: false
end

해결법

  1. ==============================

    1.2.0 이전 버전을 설치하려면 Gemfile의 AWS-SDK를 수정 :

    2.0 이전 버전을 설치하려면 Gemfile의 AWS-SDK를 수정 :

    gem 'aws-sdk', '< 2.0'
    

    이 문제는 AWS-SDK의 새 버전 (2.0 이상) 도입되었습니다. 당신은 더 여기 읽을 수 있습니다 : http://ruby.awsblog.com/post/TxFKSK2QJE6RPZ/Upcoming-Stable-Release-of-AWS-SDK-for-Ruby-Version-2

  2. ==============================

    2.공식 솔루션이 있습니다 이 지점에서 클립 사용 그것은 2 위 AWS-SDK 버전에서 작동

    공식 솔루션이 있습니다 이 지점에서 클립 사용 그것은 2 위 AWS-SDK 버전에서 작동

    gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68'
    

    단지 추가 : s3_region 매개 변수를 사용자의 클립 S3 설정에

    나를 위해 작동

  3. ==============================

    3.내 보석 폴더로 이동하고에 보석을 변경하여 작업에있어 :

    내 보석 폴더로 이동하고에 보석을 변경하여 작업에있어 :

    버전 선언은 삭제 될 수 있습니다.

    gem.lock의 오류가 발생하지 않도록하려면, 그 밖에는 보석이 업데이트됩니다, 번들 갱신 대신 번들 설치를 실행합니다.

    이제, Heroku가 로그 -t 명령은 이미지 업로드에 Heroku가 서버를 모니터링 할 수 있습니다.

    나는, 원래는 AWS 서버에 대한 새로운 오류, 액세스 거부 오류가 발생했습니다.

    이 내가 아마존에 대한 최신 날짜 활성 액세스 키 ID를 찾아 입력 최신 액세스 키 ID와 비밀 액세스 키를 사용 Heroku가 명령을 websiteand 해결하려면.

    이 Heroku가 내 이미지를 볼 수 나를 수 있었다.

    나는 많은 액세스 키 ID와 문제를 해결하기 위해 노력 비밀 액세스 키를 만들었지 만, 실제 문제가 될하기 위해 보석을 발견했다.

    팁 : 모두 저장 등 OneNote를, 메모장, 귀하의 액세스 키 정보는 반환하고이를 확인할 수 있습니다이 방법.

  4. ==============================

    4.버전 4.3를 넣고에서 사용 AWS-SDK v1로 종이 클립을 사용. 그들은 AWS-SDK v2가 포함하려고

    버전 4.3를 넣고에서 사용 AWS-SDK v1로 종이 클립을 사용. 그들은 AWS-SDK v2가 포함하려고

    공식 업그레이드 문서 https://github.com/thoughtbot/paperclip/blob/master/UPGRADING

    ##################################################
    #  NOTE FOR UPGRADING FROM 4.3.0 OR EARLIER       #
    ##################################################
    
    Paperclip is now compatible with aws-sdk >= 2.0.0.
    
    If you are using S3 storage, aws-sdk >= 2.0.0 requires you to make a few small
    changes:
    
    * You must set the `s3_region`
    * If you are explicitly setting permissions anywhere, such as in an initializer,
      note that the format of the permissions changed from using an underscore to
      using a hyphen. For example, `:public_read` needs to be changed to
      `public-read`.
    

    일부 하위 incomparability 때문에이 병합하지만 아직 공식적으로 발표되지 않은 (이 https://github.com/thoughtbot/paperclip/issues/2021 읽기), 그러나 종이 클립 V 5.0.0에 출시한다

    비탈리 Mogilevsky 언급과 같이, 당신은 지금이를 사용해야합니다 :

    # Gemfile
    # ...
    gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68'
    

    종이 클립 5.0이 출시되면, AWS-SDK v2를 포함해야한다

  5. from https://stackoverflow.com/questions/28374401/nameerror-uninitialized-constant-paperclipstorages3aws by cc-by-sa and MIT license