2017-02-10 9 views
0

リスト内のArgumentError#index(必須ではないバケットオプション) 私は何が必要かわかりません。私はペーパークリップ付きのs3を入れる過程にあります。私のエラーは6行目から来ています。私がそれを削除すれば、エラーは発生しません。リスト内のArgumentError#index(必須ではない:バケツオプション)

index.html.erb

<div class="center"> 
<div class="row"> 
    <% @listings.each do |listing| %> 
<div class="col-md-3"> 
    <div class="thumbnail"> 
    <%= image_tag listing.image.url %> 
    <div class="caption"> 
     <h3><%= listing.name %></h3> 
     <p><%= number_to_currency(listing.price) %></p> 
     <%= link_to 'Show', listing, class: "btn btn-link" %> 
     <%= link_to 'Edit', edit_listing_path(listing), class: "btn btn-link" %> 
     <%= link_to 'Destroy', listing, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-link" %> 
     </div> 
     </div> 
    </div> 
    <% end %> 
</div> 

<br> 

<%= link_to "New Listing", new_listing_path, class: "btn btn-link" %> 

モデル/ listings.rb

class Listing < ActiveRecord::Base 
    has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg" 
    validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ 
end 

端末エラー

Processing by ListingsController#index as HTML 
    Rendering listings/index.html.erb within layouts/application 
    Listing Load (1.8ms) SELECT "listings".* FROM "listings" 
    Rendered listings/index.html.erb within layouts/application (40.3ms) 
Completed 500 Internal Server Error in 101ms (ActiveRecord: 1.8ms) 



ActionView::Template::Error (missing required :bucket option): 
    3: <% @listings.each do |listing| %> 
    4:  <div class="col-md-3"> 
    5:  <div class="thumbnail"> 
    6:   <%= image_tag listing.image.url %> 
    7:   <div class="caption"> 
    8:   <h3><%= listing.name %></h3> 
    9:   <p><%= number_to_currency(listing.price) %></p> 

app/views/listings/index.html.erb:6:in `block in _app_views_listings_index_html_erb__507566283338271176_70152811711040' 
app/views/listings/index.html.erb:3:in `_app_views_listings_index_html_erb__507566283338271176_70152811711040' 
    Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout 
    Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb 
    Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (8.6ms) 
    Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb 
    Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.7ms) 
    Rendering /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb 
    Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (4.8ms) 
    Rendered /Users/chrisdionne/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (170.2ms) 

設定は/ initilizers.paperclip.rb

Paperclip::Attachment.default_options[:url] ':http://joeget.s3.amazonaws.com' 
Paperclip::Attachment.default_options[:path] = "#{Rails.root}/public/system/:class/:attachment/:id_partition/:style/:filename" 
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-east-1.amazonaws.com' 

設定/環境/ development.rb

Rails.application.configure do 

config.paperclip_defaults = { 
    storage: :s3, 
    s3_host_name: "s3_us-east-1.amazonaws.com", 
    s3_credentials: { 
    bucket: ENV['AWS_BUCKET'], 
    access_key_id: ENV['AWS_ACCESS_KEY_ID'], 
    secret_access_key: ENV['WS_SECRET_ACCESS_KEY'], 
    s3_region: ENV['AWS_REGION'], # or ENV['AWS_REGION'] 
    } 
    } 
     # Settings specified here will take precedence over those in config/application.rb. 

    # In the development environment your application's code is reloaded on 
    # every request. This slows down response time but is perfect for development 
    # since you don't have to restart the web server when you make code changes. 
    config.cache_classes = false 

    # Do not eager load code on boot. 
    config.eager_load = false 

    # Show full error reports. 
    config.consider_all_requests_local = true 

    # Enable/disable caching. By default caching is disabled. 
    if Rails.root.join('tmp/caching-dev.txt').exist? 
    config.action_controller.perform_caching = true 

    config.cache_store = :memory_store 
    config.public_file_server.headers = { 
     'Cache-Control' => 'public, max-age=172800' 
    } 
    else 
    config.action_controller.perform_caching = false 

    config.cache_store = :null_store 
    end 

    # Don't care if the mailer can't send. 
    config.action_mailer.raise_delivery_errors = false 

    config.action_mailer.perform_caching = false 

    # Print deprecation notices to the Rails logger. 
    config.active_support.deprecation = :log 

    # Raise an error on page load if there are pending migrations. 
    config.active_record.migration_error = :page_load 

# Debug mode disables concatenation and preprocessing of assets. 
    # This option may cause significant delays in view rendering with a large 
    # number of complex assets. 
    config.assets.debug = true 

    # Suppress logger output for asset requests. 
    config.assets.quiet = true 

    # Raises error for missing translations 
    # config.action_view.raise_on_missing_translations = true 

    # Use an evented file watcher to asynchronously detect changes in source code, 
    # routes, locales, etc. This feature depends on the listen gem. 
    config.file_watcher = ActiveSupport::EventedFileUpdateChecker 
end 
+0

S3用のクリップを正しく設定しましたか?あなたはそれのためのコードを投稿できますか? – Sajan

+0

こんにちはサジャン、私は最後に追加しました。あなたが何か他のものを見る必要があるかどうか私に教えてください。 – Chris

答えて

0

ペーパークリップgithubのwikiによれば、bucket構成がpaperclip_defaultsないためであるべきですs3 credentials。 like:

config.paperclip_defaults = { 
    storage: :s3, 
    s3_host_name: "s3_us-east-1.amazonaws.com", 
    bucket: ENV['AWS_BUCKET'], 
    s3_credentials: { 
    access_key_id: ENV['AWS_ACCESS_KEY_ID'], 
    secret_access_key: ENV['WS_SECRET_ACCESS_KEY'], 
    s3_region: ENV['AWS_REGION'], # or ENV['AWS_REGION'] 
    } 
} 
+0

ありがとうございました。エラーを取り除いたところ、私のページには壊れた画像がありますが、URLリンクはawsからの引き出しを示しています。どうすればこの問題を解決できますか? – Chris

+0

画像を更新しようとすると、「Aws :: Errors :: MissingRegionError in ListingsController#update regionがありません:regionオプションを使用するか、地域名をENV ['AWS_REGION']にエクスポートしてください。 – Chris

+0

リージョンを設定しましたか'ENV ['AWS_REGION']'で?あなたはAWSのキー、IDとバケットを設定したようですか? – Sajan

関連する問題