view raw
Benjamints Benjamints - 6 months ago 32
Ruby Question

ActionView::Template::Error (missing required :bucket option)

I am receiving this error on heroku logs. I am now receiving this error after creating a new bucket on amazon s3 and adding my keys. I also added my keys/bucket name to heroku, as seen here:

=== benjaminsunderland Config Vars
AWS_ACCESS_KEY_ID: my_access_key
AWS_BUCKET: mypinterestingapp
AWS_SECRET_ACCESS_KEY: my_secret_key
DATABASE_URL: my_database_url
RACK_ENV: production
RAILS_ENV: production
SECRET_KEY_BASE: my_secret_key_base

And also in enviroments/production.rb in my rails app

config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['mypinterestingapp'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']

my error in heroku logs:

2016-11-09T19:10:32.544099+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] ActionView::Template::Error (missing required :bucket option):
2016-11-09T19:10:32.544249+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 15: <tbody>
2016-11-09T19:10:32.544275+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 16: <% @pins.each do |pin| %>
2016-11-09T19:10:32.544676+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 17: <tr>
2016-11-09T19:10:32.544707+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 18: <td><%= image_tag pin.image.url %></td>
2016-11-09T19:10:32.544734+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 19: <td><%= pin.description %></td>
2016-11-09T19:10:32.544764+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 20: <td><%= if pin.user %></td>
2016-11-09T19:10:32.544790+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] 21: <td><%= link_to 'Show', pin %></td>
2016-11-09T19:10:32.544818+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537]
2016-11-09T19:10:32.544854+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] app/views/pins/index.html.erb:18:in `block in _app_views_pins_index_html_erb___1097567776692289569_70248207788000'
2016-11-09T19:10:32.544884+00:00 app[web.1]: [6df3c971-b288-4b7e-893e-dcea2f2ef537] app/views/pins/index.html.erb:16:in `_app_views_pins_index_html_erb___1097567776692289569_70248207788000'

What have I done wrong as heroku is coming up with this error, not the rails app. Do I have a typo? You can see that I named the AWS_BUCKET as exactly the same in my production.rb.


You need:

config.paperclip_defaults = {
  :storage => :s3,
  :s3_credentials => {
    :bucket => ENV['AWS_BUCKET'],
    :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
    :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']

Right now you're looking for an ENV variable called 'mypinterestingapp' when you should be looking for ENV['AWS_BUCKET'], which doesn't exist.

Also, I replaced your actual credentials in the code sample above with some generic placeholders. Never a good idea to post actual credentials in a SO question ;)