Rails partial update ActionController::UnknownFormat - ruby-on-rails
I'm trying to update a partial. Everything worked perfectşy in Rails 3 but now bumped to Rails 4.1 and I'm getting the ActionController::UnknownFormat error. I'm placing _form.html.haml into bootstrap 3 modal.
aprs_controller.rb (** is the place code gets into and I get the error)
class AprsController < ApplicationController
include Transloadit::Rails::ParamsDecoder
include AprsHelper
respond_to :html, :json, :js
def update
app = App.where('events._id' => BSON::ObjectId.from_string(params[:eventid])).first
unless app.check_user_failed == true
event = app.events.detect { |pr| pr.id.to_s == params[:eventid] }
apr = event.aprs.detect { |pr| pr.id.to_s == params[:id] }
isvalid = check_video_validity(params[:transloadit], event)
if isvalid == true
videos = transloadit_file_uploads(params[:transloadit], apr.upload)
#aprs=nil
if videos.present?
apr.upload = nil
apr.upload = videos
else
flash.now[:error] = "The time of video is wrong"
return
end
if apr.save
event = app.events.detect { |pr| pr.id.to_s == params[:eventid] }
blank = event.aprs.map{|evt| evt.upload; evt.upload.blank?}
unless blank.include? true
event.status = 4
event.save
end
**respond_to do |format|
#aprs = event.aprs
format.js
end**
end
else
flash.now[:error] = "vieo is not valid"
respond_to do |format|
#aprs = nil
format.js
end
end
else
flash.now[:error] = "user failed"
end
end
private
def apr_params
params.required(:apr).permit(:upload)
end
end
update.js.erb
$('#update_container').html("<%= j render 'form', :locals => {:aprs => #aprs} %>");
routes
resources :aprs
_form.html.haml
#update_container
- if #aprs.present?
- #aprs.each_with_index do |apr,index|
= bootstrap_form_for apr, :remote=> true, html: {"data-remote" => 'true', 'data-method' => 'post', :id => "showapr#{apr.id}" , "data-type" => :json, class: 'form-horizontal' } do |f|
= hidden_field_tag :eventid, apr.event.id
= transloadit :video_encode
.fileupload.fileupload-new.pull-left{"data-provides" => "fileupload", style: "padding-right: 5px;"}
.fileupload-preview.thumbnail{:style => "width: 140px; height: 140px;"}
- if apr.upload.present?
- if apr.upload["thumbs"].present?
%img{ :src => apr.upload["thumbs"][0], :style => "width: 140px;height: 140px;"}
-else
%img{"data-src" => "holder.js/140x140/text:Lorem ipsum/social", :src => "", :style => "width: 140px;height: 140px;"}/
- if apr.event.app.check_user_failed == false && (apr.event.start_time.day == Time.zone.now.day)
%div
%span.btn.btn-default.btn-file
%span.fileupload-new Select image
=f.file_field "upload#{apr.id}" , accept: 'video/flv,video/avi,video/mov,video/mp4,video/mpg,video/wmv,video/3gp,video/asf,video/rm,video/swf', :data => {:max_file_size => 30.megabytes}
= transloadit_jquerify "showapr#{apr.id}", :wait => true, :modal=>true, :triggerUploadOnFileSelection=> true
-else
= label_tag :error_label, "time doesn't fit to update time", class: 'control-label'
Produces this error:
ActionController::UnknownFormat - ActionController::UnknownFormat:
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:440:in `retrieve_collector_from_mimes'
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:256:in `respond_to'
app/controllers/aprs_controller.rb:40:in `update'
actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.
I registered all mime types too(even they are registered)
Mime::Type.register "text/html", :html, %w( application/xhtml+xml ), %w( xhtml )
Mime::Type.register "text/plain", :text, [], %w(txt)
Mime::Type.register "text/javascript", :js,
%w(application/javascript application/x-javascript)
Mime::Type.register "text/css", :css
Mime::Type.register "text/calendar", :ics
Mime::Type.register "text/csv", :csv
Mime::Type.register "image/png", :png, [], %w(png)
Mime::Type.register "image/jpeg", :jpeg, [], %w(jpg jpeg jpe pjpeg)
Mime::Type.register "image/gif", :gif, [], %w(gif)
Mime::Type.register "image/bmp", :bmp, [], %w(bmp)
Mime::Type.register "image/tiff", :tiff, [], %w(tif tiff)
Mime::Type.register "video/mpeg", :mpeg, [], %w(mpg mpeg mpe)
Mime::Type.register "application/xml", :xml, %w(text/xml application/x-xml)
Mime::Type.register "application/rss+xml", :rss
Mime::Type.register "application/atom+xml", :atom
Mime::Type.register "application/x-yaml", :yaml, %w( text/yaml )
Mime::Type.register "multipart/form-data", :multipart_form
Mime::Type.register "application/x-www-form-urlencoded", :url_encoded_form
Mime::Type.register "application/json", :json,
%w(text/x-json application/jsonrequest)
Mime::Type.register "application/pdf", :pdf, [], %w(pdf)
Mime::Type.register "application/zip", :zip, [], %w(zip)
Everything used to work in rails 3 didn't change the code.
Server log after the update action
Completed 200 OK in 320ms (Views: 308.7ms)
Started PATCH "/aprs/5429cf4663616e0f6d100000" for 127.0.0.1 at 2014-09-30 00:30:18 +0300
Processing by AprsController#update as HTML
Parameters: {"transloadit"=>"{\"ok\":\"ASSEMBLY_COMPLETED\",\"message\":\"The assembly was successfully completed.\",\"assembly_id\":\"c0bbb2b0481f11e4bb7fe3cde209aa37\",\"parent_id\":null,\"assembly_url\":\"http://api2.ebeny.transloadit.com/assemblies/c0bbb2b0481f11e4bb7fe3cde209aa37\",\"assembly_ssl_url\":\"https://ebeny.transloadit.com/assemblies/c0bbb2b0481f11e4bb7fe3cde209aa37\",\"bytes_received\":258018,\"bytes_expected\":258018,\"client_agent\":\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/36.0.1985.125 Chrome/36.0.1985.125 Safari/537.36\",\"client_ip\":\"85.100.75.234\",\"client_referer\":\"http://0.0.0.0:3000/apps/5429cf4563616e0f6d010000\",\"start_date\":\"2014/09/29 21:29:54 GMT\",\"is_infinite\":false,\"has_dupe_jobs\":false,\"upload_duration\":4.538,\"execution_start\":\"2014/09/29 21:29:59 GMT\",\"execution_duration\":18.362,\"notify_start\":null,\"notify_url\":null,\"notify_status\":null,\"last_job_completed\":\"2014/09/29 21:30:17 GMT\",\"notify_duration\":null,\"fields\":{},\"running_jobs\":[],\"bytes_usage\":1374741,\"executing_jobs\":[],\"started_jobs\":[],\"files_to_store_on_s3\":0,\"queued_files_to_store_on_s3\":0,\"parent_assembly_status\":null,\"params\":\"{\\\"template_id\\\":\\\"8f64b330a16f11e394d06b3e241b8964\\\"}\",\"uploads\":[{\"id\":\"c3485100481f11e494cc9bab5ef2bbe3\",\"name\":\"IMG_1561.MOV\",\"basename\":\"IMG_1561\",\"ext\":\"mov\",\"size\":257409,\"mime\":\"video/quicktime\",\"type\":\...........
flags=[]
COMMAND database=approachmachine_development command={:getlasterror=>1, :w=>1} runtime: 2.2516ms
Completed 406 Not Acceptable in 80ms
ActionController::UnknownFormat - ActionController::UnknownFormat:
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:440:in `retrieve_collector_from_mimes'
actionpack (4.1.6) lib/action_controller/metal/mime_responds.rb:256:in `respond_to'
app/controllers/aprs_controller.rb:30:in `update'
actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:282:in `block (2 levels) in halting_and_conditional'
activesupport (4.1.6) lib/active_support/core_ext/time/zones.rb:47:in `use_zone'
app/controllers/application_controller.rb:23:in `set_user_time_zone'
activesupport (4.1.6) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.6) lib/active_support/callbacks.rb:281:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:299:in `block (2 levels) in halting'
i18n (0.6.11) lib/i18n.rb:256:in `with_locale'
app/controllers/application_controller.rb:19:in `set_locale'
activesupport (4.1.6) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.6) lib/active_support/callbacks.rb:298:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.6) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.6) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.6) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.6) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
bullet (4.13.2) lib/bullet/rack.rb:12:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
i18n-js (2.1.2) lib/i18n-js/middleware.rb:11:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack-mobile-detect (0.4.0) lib/rack/mobile-detect.rb:164:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
http_accept_language (2.0.2) lib/http_accept_language/middleware.rb:13:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/error_collector.rb:50:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55: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 `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
() home/caner/.rvm/gems/ruby-2.1.2/bundler/gems/client_side_validations-e431ba00e2d7/lib/client_side_validations/middleware.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/flash.rb:254:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57: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'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
railties (4.1.6) lib/rails/engine.rb:514:in `call'
railties (4.1.6) lib/rails/application.rb:144:in `call'
railties (4.1.6) lib/rails/railtie.rb:194:in `method_missing'
newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.6) lib/rails/commands/server.rb:69:in `start'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.6) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.6) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'
Try this if this works for you..
I have done something like this in my app.
respond_to :html, :json, :js
..................................
respond_with(#users) do |format|
format.json { render :json => #user.as_json }
format.html
format.js
end
Related
Error passing time in a form when using CanCanCan
I am using the gem 'bootstrap3-datetimepicker-rails', '~> 4.17' so that the user can select a date and time, which is passed to my controller and included in the model's attributes. However, when I add load_and_authorize_resource to the controller (using cancancan), I get the following error. argument out of range The error is happening because it is passing the date January 27, 2015, but the date and month numbers are switched, and it doesn't like getting a date with month=27, hence the out of range error. However, this error is not happening in my controller, and the whole process works fine when I remove load_and_authorize_resource from the controller. How can I get this working (avoiding the error) while still authorizing the controller with cancancan? I am using Rails 4.1.4 and Ruby 2.0.0. Any guidance would be much appreciated, thanks! Edit: Adding code. damages/new.html.erb <%= simple_form_for([#car, #damage], html: {class: 'create-damage-form'}) do |f| %> <%= f.error_notification %> <div class="form-inputs"> <span class='input-group date damage-datepicker'> <%= f.text_field :date_of_damage, class: "form-control" %> <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> </span> </br> <%= f.text_area :description, class: 'form-control form-solo-field', placeholder: 'Enter a description of the damage...' %> </div> <div class="form-actions"> </br> <%= f.submit "Submit", class: "btn btn-primary btn-md" %> </div> <% end %> damages_controller.rb def create if !params[:damage][:date_of_damage].nil? date_of_damage = params[:damage][:date_of_damage] else redirect_to :back, alert: 'Enter the date of damage.' return end begin # auth_time = DateTime.strptime(auth_time, "%m-%d-%Y %H:%M%S") date_of_damage = DateTime.strptime(date_of_damage,'%m/%d/%Y') rescue ArgumentError => e redirect_to :back, alert: 'Enter a valid date.' return end #car = Car.find(params[:car_id]) damage_params_with_date = damage_params damage_params_with_date[:date_of_damage] = date_of_damage #damage = #car.damages.build(damage_params_with_date) respond_to do |format| if #damage.save format.html { redirect_to #car, notice: 'Damage record was successfully added.' } format.json { render :show, status: :created, location: #car } else format.html { redirect_to :back, alert: 'Damage record was not added.' } format.json { render json: #damage.errors, status: :unprocessable_entity } end end end partner_ability.rb can :manage, Damage, :car_id => #partner.car_ids can :create, Damage Stack Trace: Started POST "/cars/1/damages" for 127.0.0.1 at 2016-01-28 22:55:22 -0500 Processing by DamagesController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"gc5CPvSxAjwJfX4ekjEuJ1eZml9aoPxQWPfTBC2/kfc=", "damage"=>{"date_of_damage"=>"01/28/2016 10:55 PM", "description"=>"test"}, "commit"=>"Submit", "car_id"=>"1"} Completed 500 Internal Server Error in 5ms ArgumentError - argument out of range: activesupport (4.1.4) lib/active_support/values/time_zone.rb:289:in `parse' activesupport (4.1.4) lib/active_support/core_ext/string/zones.rb:9:in `in_time_zone' activerecord (4.1.4) lib/active_record/attribute_methods/time_zone_conversion.rb:37:in `date_of_damage=' activerecord (4.1.4) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute' activerecord (4.1.4) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes' activerecord (4.1.4) lib/active_record/attribute_assignment.rb:26:in `assign_attributes' activerecord (4.1.4) lib/active_record/core.rb:455:in `init_attributes' activerecord (4.1.4) lib/active_record/core.rb:198:in `initialize' activerecord (4.1.4) lib/active_record/inheritance.rb:30:in `new' cancancan (1.13.1) lib/cancan/controller_resource.rb:80:in `build_resource' cancancan (1.13.1) lib/cancan/controller_resource.rb:61:in `load_resource_instance' cancancan (1.13.1) lib/cancan/controller_resource.rb:32:in `load_resource' cancancan (1.13.1) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource' cancancan (1.13.1) lib/cancan/controller_resource.rb:10:in `block in add_before_filter' activesupport (4.1.4) lib/active_support/callbacks.rb:440:in `block in make_lambda' activesupport (4.1.4) lib/active_support/callbacks.rb:160:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:86:in `run_callbacks' actionpack (4.1.4) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (4.1.4) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.1.4) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.4) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.1.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' activerecord (4.1.4) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.1.4) lib/abstract_controller/base.rb:136:in `process' actionview (4.1.4) lib/action_view/rendering.rb:30:in `process' actionpack (4.1.4) lib/action_controller/metal.rb:196:in `dispatch' actionpack (4.1.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.1.4) lib/action_controller/metal.rb:232:in `block in action' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:82:in `dispatch' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:50:in `call' actionpack (4.1.4) lib/action_dispatch/journey/router.rb:71:in `block in call' actionpack (4.1.4) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:678:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/rack/developer_mode.rb:48:in `traced_call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78: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 `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/etag.rb:23:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/conditionalget.rb:35:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/head.rb:11:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/flash.rb:254:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/session/abstract/id.rb:225:in `context' rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:560:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' activerecord (4.1.4) lib/active_record/query_cache.rb:36:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' activerecord (4.1.4) lib/active_record/migration.rb:380:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/reloader.rb:73:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call' better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call' better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack-contrib (1.4.0) lib/rack/contrib/response_headers.rb:17:in `call' meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.4) lib/rails/rack/logger.rb:20:in `call' quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/methodoverride.rb:21:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/runtime.rb:17:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/lock.rb:17:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/sendfile.rb:112:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' railties (4.1.4) lib/rails/engine.rb:514:in `call' railties (4.1.4) lib/rails/application.rb:144:in `call' newrelic_rpm (3.14.0.305) lib/new_relic/agent/instrumentation/middleware_tracing.rb:78:in `call' rack (1.5.5) lib/rack/content_length.rb:14:in `call' thin (1.6.4) lib/thin/connection.rb:86:in `block in pre_process' thin (1.6.4) lib/thin/connection.rb:84:in `pre_process' thin (1.6.4) lib/thin/connection.rb:53:in `process' thin (1.6.4) lib/thin/connection.rb:39:in `receive_data' eventmachine (1.0.8) lib/eventmachine.rb:193:in `run' thin (1.6.4) lib/thin/backends/base.rb:73:in `start' thin (1.6.4) lib/thin/server.rb:162:in `start' rack (1.5.5) lib/rack/handler/thin.rb:16:in `run' rack (1.5.5) lib/rack/server.rb:264:in `start' railties (4.1.4) lib/rails/commands/server.rb:69:in `start' railties (4.1.4) lib/rails/commands/commands_tasks.rb:81:in `block in server' railties (4.1.4) lib/rails/commands/commands_tasks.rb:76:in `server' railties (4.1.4) lib/rails/commands/commands_tasks.rb:40:in `run_command!' railties (4.1.4) lib/rails/commands.rb:17:in `<top (required)>' bin/rails:4:in `<main>'
undefined method `[]' for nil:NilClass on mandrill mailer
I'm trying to use the mandrill_mailer gem to control transactional email, though it's returning a undefined method [] for nil:NilClass error and highlights a line in my mailer, even if I remove this line and most of the others the problem seems to persist. mailers/panel_mailer.rb class PanelMailer < MandrillMailer::TemplateMailer def blast(user, template) humans = user.humans mandrill_mail( template: 'blast-1', subject: template.subject, to: [ { email: "callum#hotmail.com", name: "Callum Short" } ], vars: { 'BG_COLOUR' => "##{user.bghex}", 'LOGO' => user.logourl_url }, template_content: {'body' => template.body}, inline_css: true, preserve_recipients: true, recipient_vars: {"callum#hotmail.com" => {'FULL_NAME' => "Callum Short"}} ) end end Full Trace: mandrill_mailer (0.5.1) lib/mandrill_mailer/template_mailer.rb:171:in `mandrill_mail' mandrill_mailer (0.5.1) lib/mandrill_mailer/core_mailer.rb:278:in `call' mandrill_mailer (0.5.1) lib/mandrill_mailer/core_mailer.rb:278:in `method_missing' actionpack (4.1.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.1.8) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.1.8) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.1.8) lib/abstract_controller/callbacks.rb:20:in `block in process_action' activesupport (4.1.8) lib/active_support/callbacks.rb:113:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:113:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.8) lib/active_support/callbacks.rb:86:in `call' activesupport (4.1.8) lib/active_support/callbacks.rb:86:in `run_callbacks' actionpack (4.1.8) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (4.1.8) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.1.8) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.8) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.1.8) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' activerecord (4.1.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.1.8) lib/abstract_controller/base.rb:136:in `process' actionview (4.1.8) lib/action_view/rendering.rb:30:in `process' actionpack (4.1.8) lib/action_controller/metal.rb:196:in `dispatch' actionpack (4.1.8) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.1.8) lib/action_controller/metal.rb:232:in `block in action' actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:82:in `call' actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:82:in `dispatch' actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:50:in `call' actionpack (4.1.8) lib/action_dispatch/journey/router.rb:73:in `block in call' actionpack (4.1.8) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.1.8) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:678:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164: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.8) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.1.8) 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.8) lib/action_dispatch/middleware/cookies.rb:560:in `call' activerecord (4.1.8) lib/active_record/query_cache.rb:36:in `call' activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call' activerecord (4.1.8) lib/active_record/migration.rb:380:in `call' actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.8) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.1.8) lib/action_dispatch/middleware/reloader.rb:73:in `call' actionpack (4.1.8) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.8) lib/rails/rack/logger.rb:20:in `call' actionpack (4.1.8) 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.8) 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.8) lib/action_dispatch/middleware/static.rb:84:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' railties (4.1.8) lib/rails/engine.rb:514:in `call' railties (4.1.8) lib/rails/application.rb:144:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service' C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service' C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run' C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Log into mailchimp, go to templates, select your template and select "send to mandrill" The error will go away :) I will do an episode in the near future on this on http://rby.io/r/5509d6
Since are using url helpers inside mailer you should define default_url_options as a hash and specify :host option as well in development.rb or production.rb (they might differ): config.mandrill_mailer.default_url_options = { host: 'localhost:3000' } The error is thrown because default_url_options are nil while url helper is trying :[] method to fetch some properties. method_missing which appears in error trace is just MandrillMailer's way to get access to Rails url helpers.
RoR - Devise Mailer - gmail refusing to send message
Currently I am working on Cloud9 and trying to create a rails app where the Devise mailer can send the reset password function and other built in mailing features. What I think is happening, is that gmail is refusing to send the message because of the account. I even went on gmail and found the cloud9 server that was sending the request and checked "This is me" for the IP address... but it still isn't working What I have tried: http://support.google.com/mail/bin/answer.py?hl=en&answer=14257&p=client_login this link allows your account to receive message requests from "less secure" applications. Changing port number - then we get a time out error rather than our current one. tried yahoo account - similar error also note that ports 25, 587, and 465 are blocked from Cloud9 to the outside. Relevant files: log/development.log: Devise::Mailer#reset_password_instructions: processed outbound mail in 646.5ms Sent mail to joeShmoe#gmail.com (60.6ms) Date: Tue, 28 Apr 2015 20:32:39 +0000 From: coolEmail#gmail.com Reply-To: coolEmail#gmail.com To: joeShmoe#gmail.com Message-ID: <553fee678a275_4542521a93097522#myAcct-1298669.mail> Subject: Reset password instructions Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit <p>Hello joeShmoe#gmail.com!</p> <p>Someone has requested a link to change your password. You can do this through the link below.</p> <p>Change my password</p> <p>If you didn't request this, please ignore this email.</p> <p>Your password won't change until you access the link above and create a new one.</p> Completed 500 Internal Server Error in 32108ms Net::OpenTimeout (execution expired): /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:541:in `initialize' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:541:in `open' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:541:in `tcp_socket' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:551:in `block in do_start' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/timeout.rb:101:in `call' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/timeout.rb:101:in `timeout' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:550:in `do_start' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:520:in `start' mail (2.6.3) lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!' mail (2.6.3) lib/mail/message.rb:2141:in `do_delivery' mail (2.6.3) lib/mail/message.rb:236:in `block in deliver' actionmailer (4.1.6) lib/action_mailer/base.rb:527:in `block in deliver_mail' activesupport (4.1.6) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.6) lib/active_support/notifications.rb:159:in `instrument' actionmailer (4.1.6) lib/action_mailer/base.rb:525:in `deliver_mail' mail (2.6.3) lib/mail/message.rb:236:in `deliver' devise (3.4.1) lib/devise/models/authenticatable.rb:178:in `send_devise_notification' devise (3.4.1) lib/devise/models/recoverable.rb:99:in `send_reset_password_instructions_notification' devise (3.4.1) lib/devise/models/recoverable.rb:49:in `send_reset_password_instructions' devise (3.4.1) lib/devise/models/recoverable.rb:116:in `send_reset_password_instructions' devise (3.4.1) app/controllers/devise/passwords_controller.rb:13:in `create' actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action' activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:86:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:86:in `run_callbacks' actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.1.6) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.6) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' activerecord (4.1.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.1.6) lib/abstract_controller/base.rb:136:in `process' actionview (4.1.6) lib/action_view/rendering.rb:30:in `process' actionpack (4.1.6) lib/action_controller/metal.rb:196:in `dispatch' actionpack (4.1.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.1.6) lib/action_controller/metal.rb:232:in `block in action' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in `call' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in `dispatch' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:50:in `call' actionpack (4.1.6) lib/action_dispatch/routing/mapper.rb:45:in `call' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:in `block in call' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164: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.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.1.6) 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.6) lib/action_dispatch/middleware/cookies.rb:560:in `call' activerecord (4.1.6) lib/active_record/query_cache.rb:36:in `call' activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call' activerecord (4.1.6) lib/active_record/migration.rb:380:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.6) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.6) lib/rails/rack/logger.rb:20:in `call' actionpack (4.1.6) 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.6) 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.6) lib/action_dispatch/middleware/static.rb:64:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' railties (4.1.6) lib/rails/engine.rb:514:in `call' railties (4.1.6) lib/rails/application.rb:144:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run' /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread' config/environments/development.rb: # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true config.action_mailer.default_url_options = { :host => 'localhost:3000' } config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: "smtp.gmail.com", port: 587, domain: ENV["gmail.com"], authentication: "plain", enable_starttls_auto: true, user_name: ENV["coolEmail#gmail.com"], password: ENV["coolPassword"], openssl_verify_mode: 'none', }
The curious case of the disappearing hash
Here is a hash: #rolesHash = {:update => {:link => 1, :task => 36}, :delete => {:link => 2, :job => 14}} I'm getting the following strange characteristics when trying to access it: #rolesHash[:update].present? # true #rolesHash[:update].class # Hash #rolesHash[:update].keys # undefined method nil for nil:NilClass #rolesHash[:update][:task] # expecting '36' but get undefined method nil for nil:NilClass Why can't I access this hash properly? Detail: Controller: 14: #recruiters = #company.recruiters 15: render layout: 'notice' View: <% #recruiters.each do |recruiter| %> <% #user = User.find_by_roleable_type_and_roleable_id("Recruiter", recruiter.id) %> <% #rolesHash = {} %> <% roles = #user.roles.where("user_id = ? AND company_id = ?", #user.id, #company.id) %> <% roles.each{|r| #rolesHash[r.role.to_sym] ||= {}; #rolesHash[r.role.to_sym][r.roleable_type.to_sym] = r.roleable_id} ... <%= #rolesHash[:delete][:job] # error ... <% end %> Trace undefined method `[]' for nil:NilClass Extracted source (around line #148): 147: 148: <%= #rolesHash[:delete][:job] %> 149: Rails.root: /Users/ss/Documents/ss/app app/views/recruiters/index.html.erb:148:in `block in _app_views_recruiters_index_html_erb__298609598644026366_70131760233080' activerecord (3.2.13) lib/active_record/relation/delegation.rb:6:in `each' activerecord (3.2.13) lib/active_record/relation/delegation.rb:6:in `each' app/views/recruiters/index.html.erb:134:in `_app_views_recruiters_index_html_erb__298609598644026366_70131760233080' actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render' activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument' actionpack (3.2.13) lib/action_view/template.rb:143:in `render' actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template' actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template' actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout' actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template' actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:154:in `block in render_with_newrelic' newrelic_rpm (3.9.4.245) lib/new_relic/agent/method_tracer.rb:234:in `trace_execution_scoped' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:153:in `render_with_newrelic' actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template' actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render' actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template' actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template' actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body' actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body' actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body' actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render' actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms' /Users/ss/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/benchmark.rb:296:in `realtime' activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime' activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render' app/controllers/recruiters_controller.rb:15:in `index' actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action' actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action' activesupport (3.2.13) lib/active_support/callbacks.rb:480:in `_run__4384579426478621208__process_action__277342749717267414__callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action' actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action' activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:32:in `block in process_action' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:365:in `perform_action_with_newrelic_trace' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:31:in `process_action' actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process' actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process' actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch' actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call' journey (1.0.4) lib/journey/router.rb:68:in `block in call' journey (1.0.4) lib/journey/router.rb:56:in `each' journey (1.0.4) lib/journey/router.rb:56:in `call' actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' omniauth (1.2.2) lib/omniauth/builder.rb:59:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' /Users/ss/.rvm/gems/ruby-2.0.0-p481/bundler/gems/rails-dev-boost-bf49caca6670/lib/rails_development_boost/async.rb:12:in `block in call' /Users/ss/.rvm/gems/ruby-2.0.0-p481/bundler/gems/rails-dev-boost-bf49caca6670/lib/rails_development_boost/async.rb:39:in `block in synchronize' /Users/ss/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' /Users/ss/.rvm/gems/ruby-2.0.0-p481/bundler/gems/rails-dev-boost-bf49caca6670/lib/rails_development_boost/async.rb:39:in `synchronize' /Users/ss/.rvm/gems/ruby-2.0.0-p481/bundler/gems/rails-dev-boost-bf49caca6670/lib/rails_development_boost/async.rb:12:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/error_collector.rb:50:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/developer_mode.rb:48:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/etag.rb:23:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/conditionalget.rb:25:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context' rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__3461156388977909965__call__2048692231345738343__callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rails-dev-tweaks (1.2.0) lib/rails_dev_tweaks/granular_autoload/middleware.rb:36:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app' railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call' activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged' railties (3.2.13) lib/rails/rack/logger.rb:16:in `call' quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' request_store (1.1.0) lib/request_store/middleware.rb:8:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/methodoverride.rb:21:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/runtime.rb:17:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/lock.rb:15:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward' rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch' rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup' rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!' rack-cache (1.2) lib/rack/cache/context.rb:51:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' railties (3.2.13) lib/rails/engine.rb:479:in `call' railties (3.2.13) lib/rails/application.rb:223:in `call' railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `method_missing' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.4.5) lib/rack/content_length.rb:14:in `call' railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call' thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process' thin (1.6.2) lib/thin/connection.rb:84:in `catch' thin (1.6.2) lib/thin/connection.rb:84:in `pre_process' thin (1.6.2) lib/thin/connection.rb:53:in `process' thin (1.6.2) lib/thin/connection.rb:39:in `receive_data' eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine' eventmachine (1.0.3) lib/eventmachine.rb:187:in `run' thin (1.6.2) lib/thin/backends/base.rb:73:in `start' thin (1.6.2) lib/thin/server.rb:162:in `start' rack (1.4.5) lib/rack/handler/thin.rb:13:in `run' rack (1.4.5) lib/rack/server.rb:268:in `start' railties (3.2.13) lib/rails/commands/server.rb:70:in `start' railties (3.2.13) lib/rails/commands.rb:55:in `block in <top (required)>' railties (3.2.13) lib/rails/commands.rb:50:in `tap' railties (3.2.13) lib/rails/commands.rb:50:in `<top (required)>' script/rails:7:in `require' script/rails:7:in `<main>'
I guess that your call to #user.roles.where("user_id = ? AND company_id = ?", #user.id, #company.id) returns no rows. This would cause roles to be empty, which in turn means roles.each doesn't iterate over anything and the block is never called. Thus, when you reach <%= #rolesHash[:delete][:job] #rolesHash is still {}, and the line is going to fail with the error you've pasted. To verify this I would start by adding two debug lines in your output. One right before iterating: <% Rails.logger.debug roles.inspect %> <% roles.each{|r| #rolesHash[r.role.to_sym] ||= {}; #rolesHash[r.role.to_sym][r.roleable_type.to_sym] = r.roleable_id} and one right before accessing #rolesHash: <% Rails.logger.debug #rolesHash.inspect %> <%= #rolesHash[:delete][:job] %> Then, looking in your logfile should allow you to see if the actual data matches the data you expect to be present.
Rails 3 to 4 wrong number of arguments error for empty hash argument
I'm having a problem updating params after I switched to strong params. I'm getting a wrong number of arguments error, here's the trace: Started PATCH "/profiles/rails/about_me" for 127.0.0.1 at 2014-09-23 12:14:19 -0700 Processing by UsersController#about_me as Parameters: {"utf8"=>"✓", "user"=>{"about_me"=>"testt"}, "commit"=>"Update Biography", "id"=>"rails"} User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."deleted" = 'f' AND "users"."id" = 10 ORDER BY "users"."id" ASC LIMIT 1 (0.2ms) SELECT COUNT(*) FROM "terms" INNER JOIN "terms_users" ON "terms"."id" = "terms_users"."term_id" WHERE "terms_users"."user_id" = $1 AND "terms"."name" = 'application' [["user_id", 10]] User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."deleted" = 'f' AND "users"."slug" = 'rails' ORDER BY "users"."id" ASC LIMIT 1 Completed 500 Internal Server Error in 14ms 127.0.0.1 POST /profiles/rails/about_me 500 Internal Server Error UsersController#about_me JS 13.8 (DB 0.0, View 0.0) {"utf8"=>"✓", "user"=>{"about_me"=>"testt"}, "commit"=>"Update Biography", "id"=>"rails"} {} ** [Airbrake] Notice was not sent due to configuration: Environment Monitored? false API key set? true ArgumentError - wrong number of arguments (2 for 1): app/models/user.rb:347:in `update_profile' app/controllers/users_controller.rb:173:in `shared_update' app/controllers/users_controller.rb:72:in `about_me' actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.1.6) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action' activesupport (4.1.6) lib/active_support/callbacks.rb:113:in `call' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.6) lib/active_support/callbacks.rb:86:in `run_callbacks' actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:in `process_action' config/initializers/log_formatter.rb:22:in `block (2 levels) in <top (required)>' activesupport (4.1.6) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.6) lib/active_support/notifications.rb:159:in `instrument' config/initializers/log_formatter.rb:21:in `block in <top (required)>' actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' activerecord (4.1.6) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (4.1.6) lib/abstract_controller/base.rb:136:in `process' actionview (4.1.6) lib/action_view/rendering.rb:30:in `process' rack-mini-profiler (0.9.2) lib/mini_profiler/profiling_methods.rb:108:in `block in profile_method' actionpack (4.1.6) lib/action_controller/metal.rb:196:in `dispatch' actionpack (4.1.6) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.1.6) lib/action_controller/metal.rb:232:in `block in action' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in `dispatch' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:50:in `call' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:in `block in call' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' apipie-rails (0.2.6) lib/apipie/static_dispatcher.rb:65:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' bullet (4.13.2) lib/bullet/rack.rb:12:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' apipie-rails (0.2.6) lib/apipie/extractor/recorder.rb:97:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/error_collector.rb:50:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/rack/developer_mode.rb:48:in `traced_call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55: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 `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/etag.rb:23:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/conditionalget.rb:35:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/head.rb:11:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/params_parser.rb:27:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/flash.rb:254:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57: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' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/cookies.rb:560:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' activerecord (4.1.6) lib/active_record/query_cache.rb:36:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.6) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' airbrake (4.1.0) lib/airbrake/rails/middleware.rb:13:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call' better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call' better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' railties (4.1.6) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.6) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.6) lib/rails/rack/logger.rb:20:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/runtime.rb:17:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' heroku-deflater (0.5.3) lib/heroku-deflater/skip_binary.rb:19:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/deflater.rb:25:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' heroku-deflater (0.5.3) lib/heroku-deflater/serve_zipped_assets.rb:50:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' airbrake (4.1.0) lib/airbrake/user_informer.rb:16:in `_call' airbrake (4.1.0) lib/airbrake/user_informer.rb:12:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:300:in `call' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' railties (4.1.6) lib/rails/engine.rb:514:in `call' railties (4.1.6) lib/rails/application.rb:144:in `call' railties (4.1.6) lib/rails/railtie.rb:194:in `method_missing' newrelic_rpm (3.9.4.245) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process' thin (1.6.2) lib/thin/connection.rb:84:in `pre_process' thin (1.6.2) lib/thin/connection.rb:53:in `process' thin (1.6.2) lib/thin/connection.rb:39:in `receive_data' eventmachine (1.0.3) lib/eventmachine.rb:187:in `run' thin (1.6.2) lib/thin/backends/base.rb:73:in `start' thin (1.6.2) lib/thin/server.rb:162:in `start' rack (1.5.2) lib/rack/handler/thin.rb:16:in `run' rack (1.5.2) lib/rack/server.rb:264:in `start' railties (4.1.6) lib/rails/commands/server.rb:69:in `start' railties (4.1.6) lib/rails/commands/commands_tasks.rb:81:in `block in server' railties (4.1.6) lib/rails/commands/commands_tasks.rb:76:in `server' railties (4.1.6) lib/rails/commands/commands_tasks.rb:40:in `run_command!' railties (4.1.6) lib/rails/commands.rb:17:in `<top (required)>' script/rails:6:in `<main>' User.rb:347:update_profile: def update_profile(attributes, options = {}) return false if attributes.nil? previous_avatar = !has_default_avatar? assign_attributes(attributes, options) if valid? if about_me_changed? || attributes[:avatar] uploaded_avatar = (attributes[:avatar].nil?)? false : true BadgesStrategies::Profile.assign_based_on(self, about_me: [about_me_was, about_me], avatar: [previous_avatar, uploaded_avatar]) end end save end UsersController:shared_update: def shared_update params[:user].delete(:password) if params[:user] && params[:user][:password].blank? params[:user].delete(:password_confirmation) if params[:user] && params[:user][:password].blank? and params[:user][:password_confirmation].blank? email_changed = params[:user] && params[:user][:email] && #user.email != params[:user][:email] if #user.update_profile(user_params) sign_in #user, bypass: true if email_changed if #user.pending_reconfirmation? flash[:notice] = "Success! Please check '#{params[:user][:email]}' for instructions to complete the update process." else flash[:notice] = "Successfully changed to '#{params[:user][:email]}'" end else flash[:notice] = "Your profile is successfully updated" end else flash[:alert] = (params[:user].nil? )? "ERROR: No user information sent for update" : "ERROR: #{#user.errors.full_messages.to_sentence}" end end UsersController:about_me: def about_me shared_update render partial: 'users/about_me', locals: { user: #user } end Could somebody look through this and tell me what exactly is going wrong? Is it a syntax error in Rails 4?
If user.rb line 347 is this line: assign_attributes(attributes, options) Then there's your problem. ActiveRecord#assign_attributes appears to only take one argument in Rails 4. See docs here Rails 3's API for the method did allow an options hash. See docs here. In rails 3, the options seems to have handled access control allowing to configure who was able to do mass assignment. In rails 4 with strong params, that responsibility has shifted to the param hash itself. The rails 4 docs state: If the passed hash responds to permitted? method and the return value of this method is false an ActiveModel::ForbiddenAttributesError exception is raised. In conclusion, when you get a message telling you that you aren't passing the right arguments to a method, the first thing you do should be to look up that method in the documentation and see how you are supposed to use it. I had no idea when I read this question what the answer was. I just found the method that you were passing two arguments into you your code, and then looked up the docs and the answer was pretty clear.