我跟着this tutorial建立回形針與Heroku的S3。它工作正常! 但現在我搬到了一個新的項目,我試圖複製我第一次使圖像上傳工作進行的步驟。但我無法做到,這讓我瘋狂!請幫我解決這個問題...我已經失去了幾個小時。 : -/回形針+的Heroku + S3問題
這就是發生了什麼事情: 我創建了一個活動選擇一張照片,我認爲上傳甚至沒有開始(它太快!)。沒有錯誤被調用,我活動的 「照片」 屬性是/photos/original/missing.png
這是我的模型文件:
class Activity < ActiveRecord::Base
has_many :infos, :dependent => :destroy
has_many :links, :dependent => :destroy
has_many :events, :dependent => :destroy
accepts_nested_attributes_for :infos
has_attached_file :photo,
:styles =>{
:thumb => "80x60#",
:medium => "160x120#",
:large => "320x240#",
:home => "320x370#"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/activities/:id/:style.:extension",
:bucket => 'andrea'
end
我的Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem "paperclip", "~> 2.3"
gem 'aws-s3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
和我s3.yml(與在的地方全鍵 「...」):
development:
bucket: andrea
access_key_id: AKIAII...
secret_access_key: vM977oy6W2TIbArCG9...
test:
bucket: andrea
access_key_id: AKIAII...
secret_access_key: vM977oy6W2TIbArCG9...
production:
bucket: andrea
access_key_id: AKIAII...
secret_access_key: vM977oy6W2TIbArCG9...
這裏的日誌:
WARNING: Can't mass-assign protected attributes: infos_attributes
[1m[36mAREL (0.3ms)[0m [1mINSERT INTO "activities" ("photo", "created_at", "updated_at", "home", "photo_file_name", "photo_content_type", "photo_file_size", "photo_updated_at", "name") VALUES (NULL, '2011-04-20 13:27:57.428869', '2011-04-20 13:27:57.428869', NULL, NULL, NULL, NULL, NULL, NULL)[0m
[paperclip] Saving attachments.
Redirected to http://localhost:3000/activities/15
Completed 302 Found in 45ms
Started GET "/activities/15" for 127.0.0.1 at 2011-04-20 15:27:57 +0200
Processing by ActivitiesController#show as HTML
Parameters: {"id"=>"15"}
[1m[35mActivity Load (0.9ms)[0m SELECT "activities".* FROM "activities" WHERE "activities"."id" = 15 LIMIT 1
Rendered activities/show.html.erb within layouts/application (13.5ms)
Completed 200 OK in 39ms (Views: 17.2ms | ActiveRecord: 1.2ms)
Started GET "/photos/large/missing.png" for 127.0.0.1 at 2011-04-20 15:27:57 +0200
ActionController::RoutingError (No route matches "/photos/large/missing.png"):
如果您需要更多信息,請告訴我!
哦,我已經試過heroku restart
,但什麼都沒有改變。
你運行回形針發電機或手動添加必要的字段的附件? – 2011-04-20 14:24:15
我確實手動添加了它們。什麼是自動執行該命令? – Abramodj 2011-04-20 15:08:00
它是'rails g paperclip activity photo',但手動添加,只要確保它們存在就可以。 – 2011-04-20 15:52:14