How to fix: Mongo::Error::OperationFailure - ruby-on-rails

The production log on my Ruby on Rails app, has some of the following error types:
Mongo::Error::OperationFailure
[225:TransactionTooOld]: Retryable write with txnNumber 12 is prohibited on session b39c1b6b-54f5-4f5d-a010-7067c095bac7
The DB has a primary instance and two replicas. I would like to know how to prevent and fix the issue. Thank you in advance
Log
mongo (2.15.0) lib/mongo/operation/result.rb:348:in `raise_operation_failure'
mongo (2.15.0) lib/mongo/operation/result.rb:314:in `validate!'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:36:in `block (3 levels) in validate_result'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:107:in `add_server_diagnostics'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:35:in `block (2 levels) in validate_result'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:54:in `add_error_labels'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:34:in `block in validate_result'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:93:in `unpin_maybe'
mongo (2.15.0) lib/mongo/operation/shared/response_handling.rb:33:in `validate_result'
mongo (2.15.0) lib/mongo/operation/shared/write.rb:49:in `block in execute'
mongo (2.15.0) lib/mongo/server/connection_pool.rb:593:in `with_connection'
mongo (2.15.0) lib/mongo/server.rb:437:in `with_connection'
mongo (2.15.0) lib/mongo/operation/shared/write.rb:38:in `execute'
mongo (2.15.0) lib/mongo/collection.rb:607:in `block (2 levels) in insert_one'
mongo (2.15.0) lib/mongo/retryable.rb:230:in `write_with_retry'
mongo (2.15.0) lib/mongo/collection.rb:596:in `block in insert_one'
mongo (2.15.0) lib/mongo/client.rb:1057:in `with_session'
mongo (2.15.0) lib/mongo/collection.rb:585:in `insert_one'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:83:in `insert_as_root'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:29:in `block in insert'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:122:in `block (2 levels) in prepare_insert'
activesupport (6.1.4) lib/active_support/callbacks.rb:106:in `run_callbacks'
mongoid (7.3.2) lib/mongoid/interceptable.rb:135:in `run_callbacks'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:121:in `block in prepare_insert'
activesupport (6.1.4) lib/active_support/callbacks.rb:98:in `run_callbacks'
mongoid (7.3.2) lib/mongoid/interceptable.rb:135:in `run_callbacks'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:120:in `prepare_insert'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:25:in `insert'
mongoid (7.3.2) lib/mongoid/persistable/savable.rb:25:in `save'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:153:in `block in create'
mongoid (7.3.2) lib/mongoid/threaded/lifecycle.rb:163:in `_creating'
mongoid (7.3.2) lib/mongoid/persistable/creatable.rb:148:in `create'
app/models/email_message.rb:32:in `email_message'
app/controllers/application_controller.rb:17:in `render_error'
app/controllers/application_controller.rb:8:in `block in <class:ApplicationController>'
activesupport (6.1.4) lib/active_support/rescuable.rb:116:in `instance_exec'
activesupport (6.1.4) lib/active_support/rescuable.rb:116:in `block in handler_for_rescue'
activesupport (6.1.4) lib/active_support/rescuable.rb:92:in `rescue_with_handler'
activesupport (6.1.4) lib/active_support/rescuable.rb:165:in `rescue_with_handler'
actionpack (6.1.4) lib/action_controller/metal/rescue.rb:25:in `rescue in process_action'
actionpack (6.1.4) lib/action_controller/metal/rescue.rb:21:in `process_action'
actionpack (6.1.4) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.4) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.4) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.4) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.4) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
mongoid (7.3.2) lib/mongoid/railties/controller_runtime.rb:22:in `process_action'
actionpack (6.1.4) lib/abstract_controller/base.rb:165:in `process'
actionpack (6.1.4) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.4) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.4) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.4) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.4) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (6.1.4) lib/action_dispatch/routing/mapper.rb:49:in `serve'
actionpack (6.1.4) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.4) lib/action_dispatch/routing/route_set.rb:842:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack-pjax (1.1.0) lib/rack/pjax.rb:12:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
newrelic_rpm (7.2.0) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
newrelic_rpm (7.2.0) lib/new_relic/rack/browser_monitoring.rb:33:in `traced_call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/cookies.rb:689:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
remotipart (1.4.4) lib/remotipart/middleware.rb:32:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:40:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/cookies.rb:689:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.4) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
logster (2.9.7) lib/logster/middleware/reporter.rb:43:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
railties (6.1.4) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.4) lib/rails/rack/logger.rb:28:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/request_id.rb:26:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
actionpack (6.1.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
newrelic_rpm (7.2.0) lib/new_relic/agent/instrumentation/middleware_tracing.rb:101:in `call'
act
database.yml
production:
clients:
default:
uri: "mongodb://user:password#[PRIMARY_IP_ADDRESS]:27017/[db_name is here]"
options:
auth_source: admin
read:
mode: :nearest
max_pool_size: 40
min_pool_size: 1
ssl: false
ssl_verify: false

It was resolved by adding the corresponding configuration for the server:
https://www.mongodb.com/docs/mongoid/7.1/tutorials/mongoid-configuration/#usage-with-forking-servers

Related

Wrong Number of Arguments Errors when upgrading Rails 5.2 to 6.0

I'm trying to upgrade an old site from Rails5.2 to 6.0 on the way to 6.1 - the recommended path.
I am getting various errors about wrong number of arguments, some of which I have managed to clear by updating or removing various gems. Finally I'm stuck on this one:
.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/static.rb:110:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)
How do I debug this and what is the underlying problem causing all the arguments errors?
Full stack track is:
/Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/static.rb:110:in `initialize': wrong number of arguments (given 3, expected 2) (ArgumentError)
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/stack.rb:37:in `new'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/stack.rb:37:in `build'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/stack.rb:131:in `block in build'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/stack.rb:127:in `each'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/stack.rb:127:in `inject'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/stack.rb:127:in `build'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/engine.rb:512:in `block in app'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/engine.rb:508:in `synchronize'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/engine.rb:508:in `app'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/application/finisher.rb:97:in `block in <module:Finisher>'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/initializable.rb:32:in `instance_exec'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/initializable.rb:32:in `run'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/initializable.rb:61:in `block in run_initializers'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/initializable.rb:60:in `run_initializers'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/application.rb:363:in `initialize!'
from /Users/will/Sites/projects/ggavatar/app/config/environment.rb:5:in `<top (required)>'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
from config.ru:3:in `block in <main>'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:77:in `log_to_stdout'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:37:in `start'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:147:in `block in perform'
from <internal:kernel>:90:in `tap'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/commands/server/server_command.rb:138:in `perform'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/command/base.rb:65:in `perform'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/command.rb:46:in `invoke'
from /Users/will/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.0.0/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
UPDATE
this blew up again shortly after the previous fix. Same error but new stack trace. I have a feeling it is to do with the cookies_serializer but I might be wrong. I have set it to hybrid according to instructions in the rails guides.
ArgumentError (wrong number of arguments (given 2, expected 1)):
json (1.8.6) lib/json/common.rb:155:in `initialize'
json (1.8.6) lib/json/common.rb:155:in `new'
json (1.8.6) lib/json/common.rb:155:in `parse'
activesupport (6.0.3.5) lib/active_support/json/decoding.rb:23:in `decode'
actionpack (6.0.3.5) lib/action_dispatch/middleware/cookies.rb:507:in `load'
actionpack (6.0.3.5) lib/action_dispatch/middleware/cookies.rb:543:in `deserialize'
actionpack (6.0.3.5) lib/action_dispatch/middleware/cookies.rb:627:in `parse'
actionpack (6.0.3.5) lib/action_dispatch/middleware/cookies.rb:461:in `[]'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/cookie_store.rb:114:in `get_cookie'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/cookie_store.rb:89:in `block (2 levels) in unpacked_cookie_data'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/abstract_store.rb:53:in `stale_session_check!'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/cookie_store.rb:88:in `block in unpacked_cookie_data'
rack (2.2.3) lib/rack/request.rb:69:in `fetch'
rack (2.2.3) lib/rack/request.rb:69:in `fetch_header'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/cookie_store.rb:87:in `unpacked_cookie_data'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/cookie_store.rb:81:in `block in extract_session_id'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/abstract_store.rb:53:in `stale_session_check!'
actionpack (6.0.3.5) lib/action_dispatch/middleware/session/cookie_store.rb:80:in `extract_session_id'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:54:in `block in id'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:53:in `fetch'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:53:in `id'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:72:in `id'
rack (2.2.3) lib/rack/session/abstract/id.rb:329:in `current_session_id'
rack (2.2.3) lib/rack/session/abstract/id.rb:335:in `session_exists?'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:203:in `exists?'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:226:in `load_for_read!'
actionpack (6.0.3.5) lib/action_dispatch/request/session.rb:92:in `[]'
warden (1.2.9) lib/warden/session_serializer.rb:31:in `fetch'
warden (1.2.9) lib/warden/proxy.rb:224:in `user'
warden (1.2.9) lib/warden/proxy.rb:334:in `_perform_authentication'
warden (1.2.9) lib/warden/proxy.rb:110:in `authenticate'
warden (1.2.9) lib/warden/proxy.rb:120:in `authenticate?'
devise (4.7.3) app/controllers/devise_controller.rb:109:in `require_no_authentication'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:428:in `block in make_lambda'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:181:in `block (2 levels) in halting_and_conditional'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:182:in `block in halting_and_conditional'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:513:in `block in invoke_before'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:513:in `each'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:513:in `invoke_before'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:134:in `run_callbacks'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.3.5) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.3.5) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.0.3.5) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.0.3.5) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.0.3.5) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.3.5) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
actionpack (6.0.3.5) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (6.0.3.5) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.5) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.5) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.5) lib/action_dispatch/routing/route_set.rb:834:in `call'
scout_apm (4.0.4) lib/scout_apm/instant/middleware.rb:53:in `call'
scout_apm (4.0.4) lib/scout_apm/middleware.rb:20:in `call'
bullet (6.1.4) lib/bullet/rack.rb:12:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.5) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.3.5) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.5) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
rollbar (3.1.2) lib/rollbar/middleware/rails/rollbar.rb:25:in `block in call'
rollbar (3.1.2) lib/rollbar.rb:145:in `scoped'
rollbar (3.1.2) lib/rollbar/middleware/rails/rollbar.rb:22:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
rollbar (3.1.2) lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
web-console (4.1.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.1.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.5) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.5) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.5) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.5) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.5) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.5) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
rack-timeout (0.6.0) lib/rack/timeout/core.rb:151:in `block in call'
rack-timeout (0.6.0) lib/rack/timeout/support/timeout.rb:19:in `timeout'
rack-timeout (0.6.0) lib/rack/timeout/core.rb:150:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.3.5) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.3.5) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
rack-mini-profiler (2.3.1) lib/mini_profiler/profiler.rb:373:in `call'
railties (6.0.3.5) lib/rails/engine.rb:527:in `call'
railties (6.0.3.5) lib/rails/railtie.rb:190:in `public_send'
railties (6.0.3.5) lib/rails/railtie.rb:190:in `method_missing'
puma (5.2.2) lib/puma/configuration.rb:248:in `call'
puma (5.2.2) lib/puma/request.rb:76:in `block in handle_request'
puma (5.2.2) lib/puma/thread_pool.rb:337:in `with_force_shutdown'
puma (5.2.2) lib/puma/request.rb:75:in `handle_request'
puma (5.2.2) lib/puma/server.rb:431:in `process_client'
puma (5.2.2) lib/puma/thread_pool.rb:145:in `block in spawn_thread'
source=rack-timeout id=27e40f2f-9e32-4ba3-9433-0da9a8037c07 timeout=15000ms service=407ms state=completed
UPDATE 2 - switch to rails 6.1.3
stack:
ArgumentError (wrong number of arguments (given 2, expected 1)):
json (1.8.6) lib/json/common.rb:155:in `initialize'
json (1.8.6) lib/json/common.rb:155:in `new'
json (1.8.6) lib/json/common.rb:155:in `parse'
activesupport (6.1.3) lib/active_support/json/decoding.rb:23:in `decode'
actionpack (6.1.3) lib/action_dispatch/middleware/cookies.rb:543:in `load'
actionpack (6.1.3) lib/action_dispatch/middleware/cookies.rb:579:in `deserialize'
actionpack (6.1.3) lib/action_dispatch/middleware/cookies.rb:668:in `parse'
actionpack (6.1.3) lib/action_dispatch/middleware/cookies.rb:482:in `[]'
actionpack (6.1.3) lib/action_dispatch/middleware/session/cookie_store.rb:114:in `get_cookie'
actionpack (6.1.3) lib/action_dispatch/middleware/session/cookie_store.rb:89:in `block (2 levels) in unpacked_cookie_data'
actionpack (6.1.3) lib/action_dispatch/middleware/session/abstract_store.rb:53:in `stale_session_check!'
actionpack (6.1.3) lib/action_dispatch/middleware/session/cookie_store.rb:88:in `block in unpacked_cookie_data'
rack (2.2.3) lib/rack/request.rb:69:in `fetch'
rack (2.2.3) lib/rack/request.rb:69:in `fetch_header'
actionpack (6.1.3) lib/action_dispatch/middleware/session/cookie_store.rb:87:in `unpacked_cookie_data'
actionpack (6.1.3) lib/action_dispatch/middleware/session/cookie_store.rb:81:in `block in extract_session_id'
actionpack (6.1.3) lib/action_dispatch/middleware/session/abstract_store.rb:53:in `stale_session_check!'
actionpack (6.1.3) lib/action_dispatch/middleware/session/cookie_store.rb:80:in `extract_session_id'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:54:in `block in id'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:53:in `fetch'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:53:in `id'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:72:in `id'
rack (2.2.3) lib/rack/session/abstract/id.rb:329:in `current_session_id'
rack (2.2.3) lib/rack/session/abstract/id.rb:335:in `session_exists?'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:203:in `exists?'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:226:in `load_for_read!'
actionpack (6.1.3) lib/action_dispatch/request/session.rb:92:in `[]'
warden (1.2.9) lib/warden/session_serializer.rb:31:in `fetch'
warden (1.2.9) lib/warden/proxy.rb:224:in `user'
warden (1.2.9) lib/warden/proxy.rb:334:in `_perform_authentication'
warden (1.2.9) lib/warden/proxy.rb:110:in `authenticate'
warden (1.2.9) lib/warden/proxy.rb:120:in `authenticate?'
devise (4.7.3) app/controllers/devise_controller.rb:109:in `require_no_authentication'
activesupport (6.1.3) lib/active_support/callbacks.rb:427:in `block in make_lambda'
activesupport (6.1.3) lib/active_support/callbacks.rb:179:in `block (2 levels) in halting_and_conditional'
actionpack (6.1.3) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
activesupport (6.1.3) lib/active_support/callbacks.rb:180:in `block in halting_and_conditional'
activesupport (6.1.3) lib/active_support/callbacks.rb:512:in `block in invoke_before'
activesupport (6.1.3) lib/active_support/callbacks.rb:512:in `each'
activesupport (6.1.3) lib/active_support/callbacks.rb:512:in `invoke_before'
activesupport (6.1.3) lib/active_support/callbacks.rb:115:in `block in run_callbacks'
activesupport (6.1.3) lib/active_support/callbacks.rb:137:in `run_callbacks'
actionpack (6.1.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.1.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.1.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.3) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.3) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.3) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.3) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.3) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
activerecord (6.1.3) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.1.3) lib/abstract_controller/base.rb:165:in `process'
actionview (6.1.3) lib/action_view/rendering.rb:39:in `process'
actionpack (6.1.3) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.3) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.3) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.3) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.3) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (6.1.3) lib/action_dispatch/routing/mapper.rb:49:in `serve'
actionpack (6.1.3) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.3) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.3) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.3) lib/action_dispatch/routing/route_set.rb:842:in `call'
scout_apm (4.0.4) lib/scout_apm/instant/middleware.rb:53:in `call'
scout_apm (4.0.4) lib/scout_apm/middleware.rb:20:in `call'
bullet (6.1.4) lib/bullet/rack.rb:12:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.1.3) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (6.1.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/cookies.rb:689:in `call'
activerecord (6.1.3) lib/active_record/migration.rb:601:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
rollbar (3.1.2) lib/rollbar/middleware/rails/rollbar.rb:25:in `block in call'
rollbar (3.1.2) lib/rollbar.rb:145:in `scoped'
rollbar (3.1.2) lib/rollbar/middleware/rails/rollbar.rb:22:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
rollbar (3.1.2) lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
web-console (4.1.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.1.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.3) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.1.3) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (6.1.3) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (6.1.3) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (6.1.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
rack-timeout (0.6.0) lib/rack/timeout/core.rb:151:in `block in call'
rack-timeout (0.6.0) lib/rack/timeout/support/timeout.rb:19:in `timeout'
rack-timeout (0.6.0) lib/rack/timeout/core.rb:150:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.1.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.3) lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
rack-mini-profiler (2.3.1) lib/mini_profiler/profiler.rb:373:in `call'
railties (6.1.3) lib/rails/engine.rb:539:in `call'
railties (6.1.3) lib/rails/railtie.rb:207:in `public_send'
railties (6.1.3) lib/rails/railtie.rb:207:in `method_missing'
puma (5.2.2) lib/puma/configuration.rb:248:in `call'
puma (5.2.2) lib/puma/request.rb:76:in `block in handle_request'
puma (5.2.2) lib/puma/thread_pool.rb:337:in `with_force_shutdown'
puma (5.2.2) lib/puma/request.rb:75:in `handle_request'
puma (5.2.2) lib/puma/server.rb:431:in `process_client'
puma (5.2.2) lib/puma/thread_pool.rb:145:in `block in spawn_thread'
source=rack-timeout id=ef317074-a4fb-4e9e-a6f4-cd2ddd1db3c5 timeout=15000ms service=367ms state=completed
EDIT - Looks like you fixed it by upgrading to a newer release. I expect if you look at the changes between your versions they will have fixed the issue I've outlined below.
I'm assuming you upgraded to Ruby 3.0.0 at the same time as upgrading Rails. I've recently done exactly the same thing, and can with some certainty say that you're hitting an issue with changes to how keyword arguments are handled in Ruby 3.
You should read this article which explains the changes: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
Here is an example of how I had to fix this within my code.
Before Ruby 3:
def self.fetch(*args)
new(*args).fetch
end
def self.update(property, category: "default", site:, value:)
args = [property, category: category, site: site]
new(*args).update(value)
end
After Ruby 3:
def self.fetch(*args, **kwargs)
new(*args, **kwargs).fetch
end
def self.update(property, category: "default", site:, value:)
args = [property]
kwargs = { category: category, site: site }
new(*args, **kwargs).update(value)
end
I found a fix for this.
There's an issue with parsing JSON:
json (1.8.6) lib/json/common.rb:155:in parse'`
The fix for that I found here: https://github.com/flori/json/issues/399#issuecomment-734863279
It means adding a config/initializers/json.rb file to override the current parse:
module JSON
module_function
def parse(source, opts = {})
Parser.new(source, **opts).parse
end
end

Adding Scope to ActiveAdmin routes getting ActionController::UrlGenerationError

I'm attempting to add a scope to the ActiveAdmin routes so that I can include the '/:brand' within the URL. SO instead of localhost:3000/admin/dashboard it would be localhost:3000/bg/admin/dashboard, with the bg being the brand.
I have my routes.rb setup like this:
Rails.application.routes.draw do
scope '/:brand', brand: /bg|gwt|acf/ do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
end
The route for logging in http://localhost:3000/bg/admin/login works perfectly fine. But once logged in I'm getting the below error for any ActiveAdmin resource.
ActionController::UrlGenerationError (No route matches {:action=>"index", :controller=>"admin/dashboard"} missing required keys: [:brand]):
actionpack (5.0.0.1) lib/action_dispatch/journey/formatter.rb:50:in `generate'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:629:in `generate'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:660:in `generate'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:707:in `url_for'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:236:in `call'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:295:in `block (2 levels) in define_url_helper'
/Users/computer/.rvm/gems/ruby-2.3.1/bundler/gems/activeadmin-f8926831429f/lib/active_admin/devise.rb:40:in `root_path'
devise (4.2.0) lib/devise/controllers/helpers.rb:178:in `signed_in_root_path'
devise (4.2.0) lib/devise/controllers/helpers.rb:214:in `after_sign_in_path_for'
devise (4.2.0) app/controllers/devise_controller.rb:114:in `require_no_authentication'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:382:in `block in make_lambda'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:150:in `block (2 levels) in halting_and_conditional'
actionpack (5.0.0.1) lib/abstract_controller/callbacks.rb:12:in `block (2 levels) in <module:Callbacks>'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:454:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:454:in `each'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:454:in `call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.0.0.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.0.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.0.1) lib/abstract_controller/base.rb:126:in `process'
actionview (5.0.0.1) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.0.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.0.1) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>'
actionpack (5.0.0.1) lib/action_dispatch/routing/mapper.rb:46:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/etag.rb:25:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:25:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/head.rb:12:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activerecord (5.0.0.1) lib/active_record/migration.rb:552:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
web-console (3.3.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.3.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack-timeout (0.4.2) lib/rack/timeout/core.rb:122:in `block in call'
rack-timeout (0.4.2) lib/rack/timeout/support/timeout.rb:19:in `timeout'
rack-timeout (0.4.2) lib/rack/timeout/core.rb:121:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'
newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
puma (3.6.0) lib/puma/configuration.rb:225:in `call'
puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
puma (3.6.0) lib/puma/server.rb:415:in `process_client'
puma (3.6.0) lib/puma/server.rb:275:in `block in run'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (4.3ms)
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms)
Rendering /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms)
Rendered /Users/computer/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (103.9ms)
source=rack-timeout id=da53bfbfe078024cf2939732b0756051 timeout=3100000ms service=578ms state=completed
Anyone have any idea why this is happening or a way to get around it? Any help is greatly appreciated. Thanks!
Found the issue. Feel a bit silly about this, but I was using a forked repo of the original ActiveAdmin. When I switched over to use the latest from the original ActiveAdmin everything works exactly like I expected it to.
Just in case someone runs into the same issue, I was using https://github.com/dtaniwaki/active_admin, which hasnt' been updated in over 4 years.
Your error is telling you that no route exists for the url you are trying to visit.
No route matches {:action=>"index", :controller=>"admin/dashboard"} missing required keys: [:brand]
Specifically, you're missing the :brand.
Where are you redirecting to after successful sign in?
It should look something like admin_root_path(brand: 'bg'). And every path helper you invoke will need to specify that :brand param.
This error sometimes indicates there is some error in some path definition,
I was defining the wrong path for the logout path for the admin session and thus got this error.

Ruby on Rails how do I create a has_one dependency on the creation of user

I am attempting to create an association between
class User
has_one :user_profile
end
class UserProfile
belongs_to :user
end
I want to create the ability to create the association when the user is created.
I have attempted things in the User Model like
before_create :build_profile
private
def build_profile
default_pararms = { some_key: value}
#profile = self.create_user_pofile!(default_params)
end
---- stack is returning ----
Redirected to http://localhost:3000/users
Completed 302 Found in 136ms (ActiveRecord: 0.3ms)
Started GET "/users" for 127.0.0.1 at 2018-03-31 01:56:40 -0400
ActionController::RoutingError (uninitialized constant UsersController):
activesupport (5.1.5) lib/active_support/inflector/methods.rb:269:in `const_get'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:269:in `block in constantize'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:267:in `each'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:267:in `inject'
activesupport (5.1.5) lib/active_support/inflector/methods.rb:267:in `constantize'
actionpack (5.1.5) lib/action_dispatch/http/request.rb:85:in `controller_class_for'
actionpack (5.1.5) lib/action_dispatch/http/request.rb:78:in `controller_class'
actionpack (5.1.5) lib/action_dispatch/routing/route_set.rb:43:in `controller'
actionpack (5.1.5) lib/action_dispatch/routing/route_set.rb:29:in `serve'
actionpack (5.1.5) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.5) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.5) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.5) lib/action_dispatch/routing/route_set.rb:844:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.4) lib/rack/etag.rb:25:in `call'
rack (2.0.4) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.4) lib/rack/head.rb:12:in `call'
rack (2.0.4) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.4) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.5) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.5) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.5) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.5) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.5) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.5) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.5) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
railties (5.1.5) lib/rails/engine.rb:522:in `call'
puma (3.11.3) lib/puma/configuration.rb:225:in `call'
puma (3.11.3) lib/puma/server.rb:624:in `handle_request'
puma (3.11.3) lib/puma/server.rb:438:in `process_client'
puma (3.11.3) lib/puma/server.rb:302:in `block in run'
puma (3.11.3) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Moved a Rails app to EC2 and now my file uploads get a Encoding::UndefinedConversionError ("\xC3" from ASCII-8BIT to UTF-8) error

I've got a Rails app that has been live for over a year with no issues, running on a custom Ubuntu/Nginx/Puma setup.
Because of various issues with the hosting company, I moved the app over to EC2 this weekend - using ElasticBeanstalk on their Nginx/Puma/Ruby2.2 stack.
Everything is working fine - apart from file uploads.
The app itself uses the Paperclip gem for handling attachments - the actual files are only held momentarily in Paperclip, before being uploaded to a file-server controlled by my client (the very first version used S3 for storage, but now it uploads, attaches the "Job-Sheet" to the Job and then immediately uploads the "Job-Sheet" to the file-server).
As I say, this was all working fine on my old server. But now, on EC2, I'm getting a Encoding::UndefinedConversionError ("\xC3" from ASCII-8BIT to UTF-8) error.
The job sheet itself can be an Excel file or a CSV. It is defined as follows:
class Job < ActiveRecord::Base
...
has_attached_file :job_sheet
validates_attachment_file_name :job_sheet, matches: [/csv\Z/, /xls\Z/, /xlsx\Z/]
validates_attachment_presence :job_sheet
...
end
The controller looks like this:
class JobsController < ApplicationController
...
def create
#job = services['creates_job'].create_job job_params, session: current_session
redirect_to jobs_path
rescue ActiveRecord::RecordInvalid
...
end
...
end
The jobs_params does the StrongParams thing of permitting the parameters as required.
And the CreatesJob service object looks like:
def create_job params, session: nil
...
job = services['jobs'].create! params.merge(code: code)
...
end
So apart from the fact that the actual logic is in a separate "CreatesJob" class, there's nothing unusual going on - pretty much a standard Rails/Paperclip upload situation.
However, some uploads are failing, with the following in the production log:
I, [2016-03-22T10:12:58.701172 #23116] INFO -- : Started POST "/jobs" for 80.0.249.70 at 2016-03-22 10:12:58 +0000
F, [2016-03-22T10:12:58.706190 #23116] FATAL -- : Encoding::UndefinedConversionError ("\xC3" from ASCII-8BIT to UTF-8):
actionpack (4.2.0) lib/action_dispatch/http/upload.rb:31:in `encode'
actionpack (4.2.0) lib/action_dispatch/http/upload.rb:31:in `initialize'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:51:in `new'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:51:in `normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:57:in `block in normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each_with_object'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:57:in `block in normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `each_with_object'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:53:in `normalize_encode_params'
actionpack (4.2.0) lib/action_dispatch/http/request.rb:308:in `POST'
actionpack (4.2.0) lib/action_dispatch/http/parameters.rb:14:in `parameters'
actionpack (4.2.0) lib/action_dispatch/http/filter_parameters.rb:37:in `filtered_parameters'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:22:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/etag.rb:24:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/conditionalget.rb:38:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/head.rb:13:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
newrelic_rpm (3.11.1.284) lib/new_relic/agent/instrumentation/middleware_tracing.rb:67:in `call'
puma (2.11.0) lib/puma/configuration.rb:82:in `call'
puma (2.11.0) lib/puma/server.rb:507:in `handle_request'
puma (2.11.0) lib/puma/server.rb:375:in `process_client'
puma (2.11.0) lib/puma/server.rb:262:in `block in run'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `call'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `block in spawn_thread'
The other answers related to this error all seem to be about forcing the encoding of the file. But the issue here seems to be 1) sometimes it's a binary (xls) and sometimes text (csv) so I can't go around mangling it and 2) the exception is in ActionDispatch; so looks like it's happening before I get to see the upload.
Any ideas what's going on and what I can do to fix it?
UPDATE: I can now reproduce the issue consistently. If I upload an XLSX file with an English filename, the upload works OK, if it's an XLSX file with Spanish accented in the filename, the upload fails as shown above.
The line in question is #original_filename.encode!(Encoding::UTF_8) in action_dispatch/http/upload.rb - however, the filename should be valid unicode, but it's obviously getting mangled in transit somewhere.

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.

Resources