我一直在AWS上一直使用CarrierWave,沒有問題,但是在我最新的項目中,我根本找不到它的工作。該文件沒有任何問題上傳到AWS,但是不是將文件位置保存在數據庫表中,而是存儲整個模型的副本。我當頁面加載時,我得到一個錯誤,因爲軌道無法弄清楚如何處理表中存儲的數據
請查看下面..直接從rails控制檯,其中profile_picture
是使用已安裝到CarrierWave的字段。爲什麼carrierwave保存整個模型的副本?
它看起來像整個對象被保存而不是生成的URL。有沒有人有這個想法?
dog = Dog.first
=> #<Dog id: 2, user_id: nil, name: "Lentil", profile_picture: "971935_556519314400437_65392555_n.jpg", breed_id: 2,
color: "fawn with black mask", age: 1, gender: "m", created_at: "2013-08-03 17:57:00", updated_at: "2013-08-03 18:12:33">
dog.profile_picture
=> #<ImageUploader:0x007f83388b70f0 @model=#<Dog id: 2, user_id: nil, name: "Lentil", profile_picture: "971935_556519314400437_65392555_n.jpg", breed_id: 2, color: "fawn with black mask", age: 1, gender: "m", created_at: "2013-08-03 17:57:00", updated_at: "2013-08-03 18:12:33">, @mounted_as=:profile_picture, @storage=#
<CarrierWave::Storage::Fog:0x007f83388b6b50 @uploader=#<ImageUploader:0x007f83388b70f0 ...>, @connection=#<Fog::Storage::AWS::Real:0x007f8336d5e3d0 @aws_access_key_id="xxx", @aws_secret_access_key="xxx", @hmac=#<Fog::HMAC:0x007f8336d5e100 @key="xxx", @digest=#<OpenSSL::Digest::Digest: xxx>, @signer=#<Proc:[email protected]/app/vendor/bundle/ruby/2.0.0/gems/fog-0.9.0/lib/fog/core/hmac.rb:22
(lambda)>>, @endpoint=nil, @host="s3.amazonaws.com", @path="/", @port=443, @scheme="https", @connection=#<Fog::Connection:0x007f8336d5db10 @excon=#<Excon::Connection:0x007f8336d5d8b8 @connection={:headers=>{}, :host=>"s3.amazonaws.com", :mock=>nil, :path=>"/", :port=>"443", :query=>nil, :scheme=>"https"}, @socket_key="s3.amazonaws.com:443">, @persistent=true>>>, @file=#<CarrierWave::Storage::Fog::File:0x007f83388b6510 @uploader=#<ImageUploader:0x007f83388b70f0
...>, @base=#<CarrierWave::Storage::Fog:0x007f83388b6b50 @uploader=#<ImageUploader:0x007f83388b70f0 ...>, @connection=#<Fog::Storage::AWS::Real:0x007f8336d5e3d0 @aws_access_key_id="xxx", @aws_secret_access_key="xxx", @hmac=#<Fog::HMAC:0x007f8336d5e100 @key="xxx", @digest=#<OpenSSL::Digest::Digest: xxx>, @signer=#<Proc:[email protected]/app/vendor/bundle/ruby/2.0.0/gems/fog-0.9.0/lib/fog/core/hmac.rb:22
(lambda)>>, @endpoint=nil, @host="s3.amazonaws.com", @path="/", @port=443, @scheme="https", @connection=#<Fog::Connection:0x007f8336d5db10 @excon=#<Excon::Connection:0x007f8336d5d8b8 @connection={:headers=>{}, :host=>"s3.amazonaws.com", :mock=>nil, :path=>"/", :port=>"443", :query=>nil, :scheme=>"https"}, @socket_key="s3.amazonaws.com:443">, @persistent=true>>>, @path="uploads/dog/profile_picture/2/971935_556519314400437_65392555_n.jpg">, @versions={}>
另外...我把'xxx'放在我的AWS密鑰和密碼是..他們不是'xxx'在我的機器上..感謝 –
你能直接從數據庫中選擇並顯示實際存儲的數據嗎? – davogones
當然..原始數據是'971011_588387701213598_486895615_n.jpg'。查詢是'SELECT * FROM dogs WHERE name ='Lentil'; '看來,霧寶石是不正確地預先與URL路徑的文件名..我已經嘗試了多種配置變化無濟於事 –