我想通过cloudinary和carrierwave在我的在线商店上传产品图片。 我按照cloudinary官方网站上的说明操作,我能够在开发环境中上传图像。但是我把它推到了heroku之后,我尝试用产品图片创建新产品,但是我得到了错误"如果你是应用程序所有者,请查看日志以获取更多信息。"
我无法在heroku日志中找到特定错误:
2015-01-09T17:40:00.955232+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bundler/gems/activeadmin-7414104d41e5/lib/active_admin/resource_controller/data_access.rb:138:in `build_new_resource' 2015-01-09T17:40:00.955231+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/inheritance.rb:61:in `new' 2015-01-09T17:40:00.949065+00:00 app[web.1]: AdminUser Load (1.7ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT 1 [["id", 1]] 2015-01-09T17:40:00.955222+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/strong_parameters.rb:188:in `each_pair' 2015-01-09T17:40:00.955234+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bundler/gems/activeadmin-7414104d41e5/lib/active_admin/resource_controller/data_access.rb:121:in `build_resource' 2015-01-09T17:40:00.955247+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/implicit_render.rb:4:in `send_action' 2015-01-09T17:40:00.955185+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:38:in `image=' 2015-01-09T17:40:00.955249+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/abstract_controller/base.rb:198:in `process_action' 2015-01-09T17:40:00.955225+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/core.rb:557:in `init_attributes' 2015-01-09T17:40:00.955264+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/abstract_controller/callbacks.rb:20:in `block in process_action' 2015-01-09T17:40:00.955274+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2 .0.rc3/lib/active_support/callbacks.rb:169:in `call' 2015-01-09T17:40:00.955266+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:117:in `call' 2015-01-09T17:40:00.955268+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:117:in `call' 2015-01-09T17:40:00.955187+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/attribute_assignment.rb:54:in `public_send' 2015-01-09T17:40:00.955271+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `call' 2015-01-09T17:40:00.955286+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `call' 2015-01-09T17:40:00.955301+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:92:in `call' 2015-01-09T17:40:00.955278+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:234:in `call' 2015-01-09T17:40:00.955227+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/core.rb:280:in `initialize' 2015-01-09T17:40:00.955306+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:81:in `run_callbacks' 2015-01-09T17:40:00.955321+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/railties/controller_runtime.rb:18:in `process_action' 2015-01-09T17:40:00.955320+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/params_wrapper.rb:250:in `process_action' 2015-01-09T17:40:00.955236+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bundler/gems/inherited_resources-9e4c7576b48e/lib/inherited_resources/actions.rb:31:in `create' 2015-01-09T17:40:00.955251+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/rendering.rb:10:in `process_action' 2015-01-09T17:40:00.955334+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/routing/route_set.rb:42:in `serve' 2015-01-09T17:40:00.955336+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/journey/router.rb:43:in `block in serve' 2015-01-09T17:40:00.955318+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/instrumentation.rb:30:in `process_action' 2015-01-09T17:40:00.955283+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:234:in `call' 2015-01-09T17:40:00.955229+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/inheritance.rb:61:in `new' 2015-01-09T17:40:00.955292+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `call' 2015-01-09T17:40:00.955289+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `call' 2015-01-09T17:40:00.955276+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `block in halting' 2015-01-09T17:40:00.955273+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `block in halting' 2015-01-09T17:40:00.955324+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionview-4.2.0.rc3/lib/action_view/rendering.rb:30:in `process' 2015-01-09T17:40:00.955303+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:92:in `_run_callbacks' 2015-01-09T17:40:00.955288+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `block in halting' 2015-01-09T17:40:00.955308+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/abstract_controller/callbacks.rb:19:in `process_action' 2015-01-09T17:40:00.955310+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/rescue.rb:29:in `process_action' 2015-01-09T17:40:00.955353+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/conditionalget.rb:38:in `call' 2015-01-09T17:40:00.955358+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/flash.rb:260:in `call' 2015-01-09T17:40:00.955331+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/routing/route_set.rb:73:in `call' 2015-01-09T17:40:00.955342+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/journey/router.rb:30:in `each' 2015-01-09T17:40:00.955269+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `block in halting' 2015-01-09T17:40:00.955300+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `block in halting' 2015-01-09T17:40:00.955313+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/notifications.rb:164:in `block in instrument' 2015-01-09T17:40:00.955346+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call' 2015-01-09T17:40:00.955323+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/abstract_controller/base.rb:137:in `process' 2015-01-09T17:40:00.955355+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/head.rb:13:in `call' 2015-01-09T17:40:00.955281+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:234:in `block in halting' 2015-01-09T17:40:00.955332+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 2015-01-09T17:40:00.955356+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/params_parser.rb:27:in `call' 2015-01-09T17:40:00.955378+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:734:in `_run_call_callbacks' 2015-01-09T17:40:00.955343+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/journey/router.rb:30:in `serve' 2015-01-09T17:40:00.955315+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 2015-01-09T17:40:00.955284+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:234:in `block in halting' 2015-01-09T17:40:00.955326+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal.rb:195:in `dispatch' 2015-01-09T17:40:00.955374+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:88:in `call' 2015-01-09T17:40:00.955381+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 2015-01-09T17:40:00.955379+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:81:in `run_callbacks' 2015-01-09T17:40:00.955316+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/notifications.rb:164:in `instrument' 2015-01-09T17:40:00.955385+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 2015-01-09T17:40:00.955291+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:169:in `block in halting' 2015-01-09T17:40:00.955359+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/session/abstract/id.rb:225:in `context' 2015-01-09T17:40:00.955329+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal.rb:236:in `block in action' 2015-01-09T17:40:00.955348+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch' 2015-01-09T17:40:00.955364+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/cookies.rb:560:in `call' 2015-01-09T17:40:00.955390+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/tagged_logging.rb:68:in `block in tagged' 2015-01-09T17:40:00.955350+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call' 2015-01-09T17:40:00.955411+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/methodoverride.rb:22:in `call' 2015-01-09T17:40:00.955409+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/request_id.rb:21:in `call' 2015-01-09T17:40:00.955305+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks' 2015-01-09T17:40:00.955352+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/etag.rb:24:in `call' 2015-01-09T17:40:00.955365+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/query_cache.rb:36:in `call' 2015-01-09T17:40:00.955376+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/callbacks.rb:88:in `_run_callbacks' 2015-01-09T17:40:00.955388+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/rack/logger.rb:20:in `block in call' 2015-01-09T17:40:00.955431+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 2015-01-09T17:40:00.955394+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/rack/logger.rb:20:in `call' 2015-01-09T17:40:00.955418+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/sendfile.rb:113:in `call' 2015-01-09T17:40:00.955387+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/rack/logger.rb:38:in `call_app' 2015-01-09T17:40:00.955413+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/runtime.rb:18:in `call' 2015-01-09T17:40:00.955373+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' 2015-01-09T17:40:00.955362+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/session/abstract/id.rb:220:in `call' 2015-01-09T17:40:00.955393+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/tagged_logging.rb:68:in `tagged' 2015-01-09T17:40:00.955416+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/static.rb:113:in `call' 2015-01-09T17:40:00.955423+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/lock.rb:17:in `call' 2015-01-09T17:40:00.955311+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' 2015-01-09T17:40:00.955414+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 2015-01-09T17:40:00.955428+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 2015-01-09T17:40:00.955421+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:164:in `call' 2015-01-09T17:40:00.955433+00:00 app[web.1]: 2015-01-09T17:40:00.955419+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:518:in `call' 2015-01-09T17:40:00.955391+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/tagged_logging.rb:26:in `tagged' 2015-01-09T17:40:00.955425+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/content_length.rb:15:in `call' 2015-01-09T17:40:00.955382+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/remote_ip.rb:78:in `call' 2015-01-09T17:40:00.955327+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' 2015-01-09T17:40:00.955426+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0.beta2/lib/rack/handler/webrick.rb:89:in `service' 2015-01-09T17:40:00.955434+00:00 app[web.1]: 2015-01-09T17:40:00.955430+00:00 app[web.1]: vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 2015-01-09T17:40:00.955345+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/routing/route_set.rb:802:in `call' 2015-01-09T17:40:00.955371+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0.rc3/lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call' 2015-01-09T17:40:00.955384+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0.rc3/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
形式:
form(:html => { :multipart => true }) do |f|
f.inputs 'New product' do
...
f.file_field :image, label: 'Image'
f.submit
end
end
者:
class ImageUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
end
型号:
class Product < ActiveRecord::Base
...
mount_uploader :image, ImageUploader
...
end
控制器:
def create
@product = Product.new(product_params)
respond_to do |format|
if @product.save
format.html { redirect_to @product }
else
format.html { render :new, notice: 'Errors.' }
end
end
end
def product_params
params.require(:product).permit(:title, :short_description, :description, :image, :price)
end
我有Rails 4.2.0