Closed jgrannas closed 9 years ago
I cannot figure out what is causing this TypeError. I have another rails app on Rails 4.0.3 where it works, and this Rails 4.1.5 app does not work.
class ImagesController < ApplicationController load_and_authorize_resource before_action :set_image, only: [:destroy] def create p_attr = params[:image] p_attr[:gallery_id] = params[:image][:gallery_id] p_attr[:file] = params[:image][:file].first if params[:image][:file].class == Array @image = Image.new(p_attr) if @image.save respond_to do |format| format.js format.html { render :json => [@image.to_jq_upload].to_json, :content_type => 'text/html', :layout => false } format.json { render :json => { :files => [@image.to_jq_upload] } } end else render :json => [{:error => "custom_failure"}], :status => 304 end end def destroy @image.destroy render :json => true end private # Use callbacks to share common setup or constraints between actions. def set_image @image = Image.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def image_params params.require(:image).permit(:gallery_id, file:[]) end end
Started POST "/images" for 127.0.0.1 at 2014-10-02 13:48:39 -0400 Processing by ImagesController#create as JSON Parameters: {"utf8"=>"✓", "authenticity_token"=>"6pvN7Ssl0Epye/CaUXKuakDItf1MkJi3KGA200Kwgvs=", "image"=>{"gallery_id"=>"3", "file"=>[#<ActionDispatch::Http::UploadedFile:0x007ff23c3d0730 @tempfile=#<Tempfile:/var/folders/3m/t1v11gzj32n0fdbhwr823y600000gn/T/RackMultipart20141002-38945-pt6cs6>, @original_filename="P7310618.JPG", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"image[file][]\"; filename=\"P7310618.JPG\"\r\nContent-Type: image/jpeg\r\n">]}} Completed 500 Internal Server Error in 24ms TypeError (no implicit conversion of nil into String): carrierwave (0.10.0) lib/carrierwave/uploader/cache.rb:159:in `join' carrierwave (0.10.0) lib/carrierwave/uploader/cache.rb:159:in `cache_path' carrierwave (0.10.0) lib/carrierwave/uploader/cache.rb:131:in `block in cache!' carrierwave (0.10.0) lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks' carrierwave (0.10.0) lib/carrierwave/uploader/cache.rb:122:in `cache!' carrierwave (0.10.0) lib/carrierwave/mount.rb:329:in `cache' carrierwave (0.10.0) lib/carrierwave/mount.rb:163:in `file=' carrierwave (0.10.0) lib/carrierwave/orm/activerecord.rb:39:in `file=' activerecord (4.1.5) lib/active_record/attribute_assignment.rb:45:in `public_send' activerecord (4.1.5) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute' activerecord (4.1.5) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes' activerecord (4.1.5) lib/active_record/attribute_assignment.rb:26:in `each' activerecord (4.1.5) lib/active_record/attribute_assignment.rb:26:in `assign_attributes' activerecord (4.1.5) lib/active_record/core.rb:455:in `init_attributes' activerecord (4.1.5) lib/active_record/core.rb:198:in `initialize' actionpack (4.1.5) lib/action_dispatch/routing/url_for.rb:104:in `initialize' activerecord (4.1.5) lib/active_record/inheritance.rb:30:in `new' activerecord (4.1.5) lib/active_record/inheritance.rb:30:in `new' cancancan (1.9.2) lib/cancan/controller_resource.rb:85:in `build_resource' cancancan (1.9.2) lib/cancan/controller_resource.rb:66:in `load_resource_instance' cancancan (1.9.2) lib/cancan/controller_resource.rb:32:in `load_resource' cancancan (1.9.2) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource' cancancan (1.9.2) lib/cancan/controller_resource.rb:10:in `block in add_before_filter' activesupport (4.1.5) lib/active_support/callbacks.rb:440:in `instance_exec' activesupport (4.1.5) lib/active_support/callbacks.rb:440:in `block in make_lambda' activesupport (4.1.5) lib/active_support/callbacks.rb:160:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:160:in `block in halting' activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `call' activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `run_callbacks' actionpack (4.1.5) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (4.1.5) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.1.5) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.1.5) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.5) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.1.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.1.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' activerecord (4.1.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.1.5) lib/abstract_controller/base.rb:136:in `process' actionview (4.1.5) lib/action_view/rendering.rb:30:in `process' actionpack (4.1.5) lib/action_controller/metal.rb:196:in `dispatch' actionpack (4.1.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.1.5) lib/action_controller/metal.rb:232:in `block in action' actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:82:in `call' actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:82:in `dispatch' actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:50:in `call' actionpack (4.1.5) lib/action_dispatch/journey/router.rb:71:in `block in call' actionpack (4.1.5) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.1.5) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:678:in `call' jquery-fileupload-rails (0.4.1) lib/jquery/fileupload/rails/middleware.rb:14:in `_call' jquery-fileupload-rails (0.4.1) lib/jquery/fileupload/rails/middleware.rb:10:in `call' warden (1.2.3) lib/warden/manager.rb:35:in `block in call' warden (1.2.3) lib/warden/manager.rb:34:in `catch' warden (1.2.3) lib/warden/manager.rb:34:in `call' rack (1.5.2) lib/rack/etag.rb:23:in `call' rack (1.5.2) lib/rack/conditionalget.rb:35:in `call' rack (1.5.2) lib/rack/head.rb:11:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/flash.rb:254:in `call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/cookies.rb:560:in `call' activerecord (4.1.5) lib/active_record/query_cache.rb:36:in `call' activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call' activerecord (4.1.5) lib/active_record/migration.rb:380:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.5) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/reloader.rb:73:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.1.5) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.5) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.5) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.5) lib/rails/rack/logger.rb:20:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' rack (1.5.2) lib/rack/runtime.rb:17:in `call' activesupport (4.1.5) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' actionpack (4.1.5) lib/action_dispatch/middleware/static.rb:64:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' railties (4.1.5) lib/rails/engine.rb:514:in `call' railties (4.1.5) lib/rails/application.rb:144:in `call' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:155:in `handle' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:109:in `rescue in block (2 levels) in start' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:106:in `block (2 levels) in start' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:96:in `each' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:96:in `block in start' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:76:in `loop' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:76:in `start' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/lib/nack/server.rb:12:in `run' /Users/joel/Library/Application Support/Pow/Versions/0.4.3/node_modules/nack/bin/nack_worker:4:in `<main>' Rendered /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.5ms) Rendered /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb (0.5ms) Rendered /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb (0.7ms) Rendered /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb (13.5ms)
Not a bug, exception happens in carrierwave. My guess wrong params hash or form encoding (should be multipart when using form upload).
I cannot figure out what is causing this TypeError. I have another rails app on Rails 4.0.3 where it works, and this Rails 4.1.5 app does not work.