Ruby on rails with AJAX - Very simply calculator - ruby-on-rails

This is my first ruby on rails application. I want to make a very simple calculator, but it doesn't calculate. I want to calculate on the server site. Code below
routes.rb:
Rails.application.routes.draw do
get 'calculators/new'
get 'calculators/create'
resources :calculators
root to: 'calculators#new'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
app\views\calculators\create.html.erb
document.getElementById("sum").innerHTML = <%= #sum %>
app\views\calculators\new.html.erb
<%= form_tag calculators_path, :method => :post, :remote => true do %>
<%= text_field_tag :data, nil, :onkeyup => "this.form.sub.click()" %> = <span id="sum"></span>
<%= submit_tag "ok", :name => "sub"%>
<% end %>
app\controllers\calculators_controller.rb
class CalculatorsController < ApplicationController
def create
#sum = eval(params[:data])
end
end
The following errors appear in the logs:
BROWSER
SyntaxError in CalculatorsController#create
(eval):1: syntax error, unexpected end-of-input
Rails.root: /home/crancode/Desktop/studia/zad3_v3
Application Trace
(eval):1: syntax error, unexpected end-of-input
(eval):1: syntax error, unexpected end-of-input
(eval):1: syntax error, unexpected end-of-input
app/controllers/calculators_controller.rb:3:in `eval'
app/controllers/calculators_controller.rb:3:in `create'
Framework Trace
actionpack (6.1.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.1.1) lib/abstract_controller/base.rb:228:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.1.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.1.1) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
actiontext (6.1.1) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (6.1.1) lib/action_text/engine.rb:55:in `block (4 levels) in <class:Engine>'
activesupport (6.1.1) lib/active_support/callbacks.rb:126:in `instance_exec'
activesupport (6.1.1) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
activesupport (6.1.1) lib/active_support/callbacks.rb:137:in `run_callbacks'
actionpack (6.1.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.1) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.1) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.1) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
activerecord (6.1.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.1.1) lib/abstract_controller/base.rb:165:in `process'
actionview (6.1.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.1.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.1) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.1) lib/action_dispatch/routing/route_set.rb:842: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:40:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.1.1) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (6.1.1) 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.1) lib/action_dispatch/middleware/cookies.rb:689:in `call'
activerecord (6.1.1) lib/active_record/migration.rb:601:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
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.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.1) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.1.1) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (6.1.1) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (6.1.1) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (6.1.1) 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.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.1.1) 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.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
rack-mini-profiler (2.3.1) lib/mini_profiler/profiler.rb:373:in `call'
webpacker (5.2.1) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.1.1) lib/rails/engine.rb:539:in `call'
puma (5.2.0) lib/puma/configuration.rb:247:in `call'
puma (5.2.0) lib/puma/request.rb:76:in `block in handle_request'
puma (5.2.0) lib/puma/thread_pool.rb:337:in `with_force_shutdown'
puma (5.2.0) lib/puma/request.rb:75:in `handle_request'
puma (5.2.0) lib/puma/server.rb:432:in `process_client'
puma (5.2.0) lib/puma/thread_pool.rb:145:in `block in spawn_thread'
Full Trace
(eval):1: syntax error, unexpected end-of-input
(eval):1: syntax error, unexpected end-of-input
(eval):1: syntax error, unexpected end-of-input
app/controllers/calculators_controller.rb:3:in `eval'
app/controllers/calculators_controller.rb:3:in `create'
actionpack (6.1.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.1.1) lib/abstract_controller/base.rb:228:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.1.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.1.1) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
actiontext (6.1.1) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (6.1.1) lib/action_text/engine.rb:55:in `block (4 levels) in <class:Engine>'
activesupport (6.1.1) lib/active_support/callbacks.rb:126:in `instance_exec'
activesupport (6.1.1) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
activesupport (6.1.1) lib/active_support/callbacks.rb:137:in `run_callbacks'
actionpack (6.1.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.1) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.1) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.1) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.1) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
activerecord (6.1.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.1.1) lib/abstract_controller/base.rb:165:in `process'
actionview (6.1.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.1.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.1) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.1) lib/action_dispatch/routing/route_set.rb:842: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:40:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.1.1) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (6.1.1) 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.1) lib/action_dispatch/middleware/cookies.rb:689:in `call'
activerecord (6.1.1) lib/active_record/migration.rb:601:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
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.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.1) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.1.1) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (6.1.1) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (6.1.1) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (6.1.1) 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.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.1.1) 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.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.1) lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
rack-mini-profiler (2.3.1) lib/mini_profiler/profiler.rb:373:in `call'
webpacker (5.2.1) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.1.1) lib/rails/engine.rb:539:in `call'
puma (5.2.0) lib/puma/configuration.rb:247:in `call'
puma (5.2.0) lib/puma/request.rb:76:in `block in handle_request'
puma (5.2.0) lib/puma/thread_pool.rb:337:in `with_force_shutdown'
puma (5.2.0) lib/puma/request.rb:75:in `handle_request'
puma (5.2.0) lib/puma/server.rb:432:in `process_client'
puma (5.2.0) lib/puma/thread_pool.rb:145:in `block in spawn_thread'
Request parameters
{"data"=>"2+",
"sub"=>"ok"}
Session dump
_csrf_token: "_HyGon2ni-rzV2v9haqyAKOPGTk52oSq7TpklxT1dgQ="
session_id: "de90be13838026449531cd93bdf17f15"
Env dump
GATEWAY_INTERFACE: "CGI/1.2"
HTTP_ACCEPT: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"
HTTP_ACCEPT_ENCODING: "gzip, deflate"
HTTP_ACCEPT_LANGUAGE: "en-US,en;q=0.5"
HTTP_ORIGIN: "http://localhost:3000"
HTTP_VERSION: "HTTP/1.1"
HTTP_X_CSRF_TOKEN: "Eng2-4pM0KCUfSpu_-pydplFUCbeurmEXlxnqVSQVNVNvw77fkYwl2-D28WD053sqIgavIUb7n8J8BLoUO-q9w"
ORIGINAL_SCRIPT_NAME: ""
REMOTE_ADDR: "127.0.0.1"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"
Response headers
None
SERVER
Started POST "/calculators" for 127.0.0.1 at 2021-01-30 15:23:17 +0100
Processing by CalculatorsController#create as JS
Parameters: {"data"=>"2+", "sub"=>"ok"}
Completed 500 Internal Server Error in 1ms (Allocations: 613)
SyntaxError ((eval):1: syntax error, unexpected end-of-input):
(eval):1: syntax error, unexpected end-of-input
(eval):1: syntax error, unexpected end-of-input
(eval):1: syntax error, unexpected end-of-input
app/controllers/calculators_controller.rb:3:in `eval'
app/controllers/calculators_controller.rb:3:in `create'
Started POST "/calculators" for 127.0.0.1 at 2021-01-30 15:23:18 +0100
Processing by CalculatorsController#create as JS
Parameters: {"data"=>"2+2", "sub"=>"ok"}
Rendering layout layouts/application.html.erb
Rendering calculators/create.html.erb within layouts/application
Rendered calculators/create.html.erb within layouts/application (Duration: 0.1ms | Allocations: 39)
[Webpacker] Everything's up-to-date. Nothing to do
Rendered layout layouts/application.html.erb (Duration: 8.5ms | Allocations: 3015)
Completed 200 OK in 10ms (Views: 9.3ms | Allocations: 3449)
Thanks

I changed filename from create.html.erb to create.js.erb and it works. Thanks for tips.

Related

Attempting to register a user on my devise app causes undefined method `user_url' for #<Devise::RegistrationsController:0x0000000000d9d0>

I am getting this error when I try to sign up a user. After this error, I'm still able to sign in with the user it would've created, but it always shows me this upon registration. Please let me know if there's other information you need. Been stumped on this for a few days.
Here is the exception causes:
Here is the callback for the error:
actionpack (7.0.0) lib/action_dispatch/routing/polymorphic_routes.rb:231:in `public_send'
actionpack (7.0.0) lib/action_dispatch/routing/polymorphic_routes.rb:231:in `polymorphic_method'
actionpack (7.0.0) lib/action_dispatch/routing/polymorphic_routes.rb:116:in `polymorphic_url'
actionpack (7.0.0) lib/action_dispatch/routing/url_for.rb:187:in `full_url_for'
actionpack (7.0.0) lib/action_dispatch/routing/url_for.rb:170:in `url_for'
actionpack (7.0.0) lib/action_controller/metal/redirecting.rb:144:in `_compute_redirect_to_location'
actionpack (7.0.0) lib/action_controller/metal/redirecting.rb:89:in `redirect_to'
actionpack (7.0.0) lib/action_controller/metal/flash.rb:62:in `redirect_to'
actionpack (7.0.0) lib/action_controller/metal/instrumentation.rb:42:in `block in redirect_to'
activesupport (7.0.0) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.0) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.0) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.0) lib/action_controller/metal/instrumentation.rb:41:in `redirect_to'
responders (3.0.1) lib/action_controller/responder.rb:147:in `redirect_to'
responders (3.0.1) lib/action_controller/responder.rb:207:in `navigation_behavior'
responders (3.0.1) lib/action_controller/responder.rb:174:in `rescue in to_html'
responders (3.0.1) lib/action_controller/responder.rb:171:in `to_html'
responders (3.0.1) lib/action_controller/responder.rb:165:in `respond'
responders (3.0.1) lib/action_controller/responder.rb:158:in `call'
responders (3.0.1) lib/action_controller/respond_with.rb:213:in `respond_with'
devise (4.8.1) app/controllers/devise/registrations_controller.rb:25:in `create'
actionpack (7.0.0) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.0) lib/abstract_controller/base.rb:214:in `process_action'
actionpack (7.0.0) lib/action_controller/metal/rendering.rb:53:in `process_action'
actionpack (7.0.0) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.0) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
actiontext (7.0.0) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (7.0.0) lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
activesupport (7.0.0) lib/active_support/callbacks.rb:127:in `instance_exec'
activesupport (7.0.0) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.0) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.0) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.0) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (7.0.0) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.0) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.0) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.0) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.0) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.0) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.0) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.0) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.0) lib/action_view/rendering.rb:39:in `process'
actionpack (7.0.0) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.0) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.0) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.0) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.0) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
actionpack (7.0.0) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.0) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.0) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.0) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.0) lib/action_dispatch/routing/route_set.rb:850: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:40:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (7.0.0) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (7.0.0) 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 (7.0.0) lib/action_dispatch/middleware/cookies.rb:693:in `call'
activerecord (7.0.0) lib/active_record/migration.rb:603:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.0) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.0) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
railties (7.0.0) lib/rails/rack/logger.rb:36:in `call_app'
railties (7.0.0) lib/rails/rack/logger.rb:25:in `block in call'
activesupport (7.0.0) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (7.0.0) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (7.0.0) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (7.0.0) lib/rails/rack/logger.rb:25:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.0) 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 (7.0.0) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/server_timing.rb:20:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/static.rb:23:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.0) lib/action_dispatch/middleware/host_authorization.rb:137:in `call'
railties (7.0.0) lib/rails/engine.rb:530:in `call'
puma (5.5.2) lib/puma/configuration.rb:249:in `call'
puma (5.5.2) lib/puma/request.rb:77:in `block in handle_request'
puma (5.5.2) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
puma (5.5.2) lib/puma/request.rb:76:in `handle_request'
puma (5.5.2) lib/puma/server.rb:447:in `process_client'
puma (5.5.2) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
My routes.rb:
Rails.application.routes.draw do
devise_for :users
resources :teachers
resources :offices
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Defines the root path route ("/")
root to: "offices#index"
# root "articles#index"
end
This seems to a be a known issue with Rails 7 and Devise now. To fix it in the meantime simply add the following line to your devise.rb.
config.navigational_formats = ['*/*', :html, :turbo_stream]
Source:
https://github.com/heartcombo/devise/issues/5439

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

Edgeguides' Getting Started with Rails template missing error

I just began learning ruby on rails and while going through the guide link, I cannot change the page display in step 4.3
my routes.rb file looks precisely as recommended in the guide, having only two lines between the draw and its end:
get 'welcome/index'
root 'welcome#index'
while my index.html.erb file looks like this:
<h1>Hello, Rails!</h1>
yet when I load the localhost:3000 page, it gives the error
WelcomeController#index is missing a template for request formats:
text/html
even though the file index.html.erb is valid.
any suggestions for what could be the matter?
EDIT: Server log reads as follows:
Started GET "/welcome/index" for ::1 at 2020-02-12 15:19:39 -0500 (5.7ms) SELECT sqlite_version(*) Processing by WelcomeController#index as HTML Completed 406 Not Acceptable in 28ms (ActiveRecord: 0.0ms | Allocations: 1989)
ActionController::MissingExactTemplate (WelcomeController#index is missing a template for request formats: text/html):
actionpack (6.0.2.1) lib/action_controller/metal/implicit_render.rb:45:in `default_render'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:196:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.2.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.2.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.2.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (6.0.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:837:in `call'
rack (2.2.2) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.2) lib/rack/etag.rb:27:in `call'
rack (2.2.2) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.2) lib/rack/head.rb:12:in `call'
actionpack (6.0.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.2) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.2) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.2.1) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.2) lib/rack/method_override.rb:24:in `call'
rack (2.2.2) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
puma (4.3.1) lib/puma/configuration.rb:228:in `call'
puma (4.3.1) lib/puma/server.rb:681:in `handle_request'
puma (4.3.1) lib/puma/server.rb:472:in `process_client'
puma (4.3.1) lib/puma/server.rb:328:in `block in run'
puma (4.3.1) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
I have also tried continuing to follow the guide to step 5.1 and though all the errors appear as the guide says, the 'solution' at the end of that step still causes an error with template format.

Another ActionController::InvalidAuthenticityToken in Rails 6

I am working on running a Rails application in production. It's still a proof of concept, but I'm running into ActionController::InvalidAuthenticityToken exceptions for form submissions. My understanding is that in Rails 6 (or maybe earlier?) the protect_from_forgery callback is now called by default. To get it to work, I added the configuration option config.action_controller.allow_forgery_protection = false in my config/environments/production.rb file, and now I'm working on re-enabling forgery protection so I removed the override and attempted to submit some forms (or log out, basically anything that uses a POST/PUT/PATCH/DELETE method).
My ApplicationController does not call protect_from_forgery manually, and all GET requests appear to be working just fine. My application.html.haml includes the following within %head:
= csrf_meta_tags
= csp_meta_tag
My forms are using bootstrap_form_with and the form is submitting an authenticity_token form parameter that matches what is in the %head (verified from Chrome dev tools and the logs). When I submit, I see that the response is a 422 error with the exception in the logs:
[3d603471-3240-4401-a3a2-e9ba3c6ac358] ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
[3d603471-3240-4401-a3a2-e9ba3c6ac358]
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/request_forgery_protection.rb:217:in `handle_unverified_request'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/request_forgery_protection.rb:249:in `handle_unverified_request'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] devise (4.7.1) lib/devise/controllers/helpers.rb:255:in `handle_unverified_request'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/request_forgery_protection.rb:244:in `verify_authenticity_token'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:429:in `block in make_lambda'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:201:in `block (2 levels) in halting'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:202:in `block in halting'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:514:in `block in invoke_before'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:514:in `each'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:514:in `invoke_before'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:110:in `block in run_callbacks'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] ahoy_matey (3.0.1) lib/ahoy/controller.rb:45:in `set_ahoy_request_store'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:121:in `block in run_callbacks'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:139:in `run_callbacks'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `block in instrument'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `instrument'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activerecord (6.0.2.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/abstract_controller/base.rb:136:in `process'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionview (6.0.2.1) lib/action_view/rendering.rb:39:in `process'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal.rb:191:in `dispatch'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_controller/metal.rb:252:in `dispatch'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/routing/mapper.rb:48:in `serve'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:49:in `block in serve'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `each'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `serve'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:837:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] warden (1.2.8) lib/warden/manager.rb:34:in `catch'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] warden (1.2.8) lib/warden/manager.rb:34:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/tempfile_reaper.rb:15:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/etag.rb:25:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/conditional_get.rb:38:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/head.rb:12:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/session/abstract/id.rb:259:in `context'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/session/abstract/id.rb:253:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/cookies.rb:648:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] turbolinks_render (0.9.17) lib/turbolinks_render/middleware.rb:77:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] ahoy_matey (3.0.1) lib/ahoy/engine.rb:22:in `call_with_quiet_ahoy'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/method_override.rb:22:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/runtime.rb:22:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] rack (2.0.8) lib/rack/sendfile.rb:111:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:77:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] puma (4.3.1) lib/puma/configuration.rb:228:in `call'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] puma (4.3.1) lib/puma/server.rb:681:in `handle_request'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] puma (4.3.1) lib/puma/server.rb:472:in `process_client'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] puma (4.3.1) lib/puma/server.rb:328:in `block in run'
[3d603471-3240-4401-a3a2-e9ba3c6ac358] puma (4.3.1) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
I saw that devise recommended that I use prepend on the forgery protection, so I added the following to the ApplicationController:
protect_from_forgery with: :exception, prepend: true
I'm a bit stumped as to why this is happening, and can certainly provide some more code samples, but I'm not entirely sure what is necessary.
Thanks so much
In my case, solving this involved enabling the option in config/environments/production.rb as shown:
config.force_ssl = true
I'm not sure if this is the only thing, unfortunately, since it was a while since I asked the question, however, after I enabled it request forgery protection started working.

Undefined method `show_previews' for ActionMailer::Base:Class

I have this error when I try the test of mail.
NoMethodError in Rails::MailersController#index
undefined method `show_previews' for ActionMailer::Base:Class
Extracted source (around line #49):
private
def show_previews? # :doc:
ActionMailer::Base.show_previews
end
def find_preview # :doc:
I have searched in google but I can not find anything
Rails version: 5.2.1
=> Booting Puma
=> Rails 5.2.1 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.3.3-p222), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Complete log:
Started GET "/rails/mailers/register_mailer/new_user" for 127.0.0.1 at 2019-01-07 13:33:30 +0100
Processing by Rails::MailersController#preview as HTML
Parameters: {"path"=>"register_mailer/new_user"}
Completed 500 Internal Server Error in 16ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `show_previews' for ActionMailer::Base:Class):
railties (5.2.1) lib/rails/mailers_controller.rb:49:in `show_previews?'
activesupport (5.2.1) lib/active_support/callbacks.rb:435:in `block in inverted_lambda'
activesupport (5.2.1) lib/active_support/callbacks.rb:178:in `block (2 levels) in halting_and_conditional'
activesupport (5.2.1) lib/active_support/callbacks.rb:178:in `each'
activesupport (5.2.1) lib/active_support/callbacks.rb:178:in `all?'
activesupport (5.2.1) lib/active_support/callbacks.rb:178:in `block in halting_and_conditional'
activesupport (5.2.1) lib/active_support/callbacks.rb:513:in `block in invoke_before'
activesupport (5.2.1) lib/active_support/callbacks.rb:513:in `each'
activesupport (5.2.1) lib/active_support/callbacks.rb:513:in `invoke_before'
activesupport (5.2.1) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.1) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.1) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.1) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.1) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.1) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.1) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.1) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.1) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.1) lib/action_dispatch/routing/route_set.rb:840:in `call'
rack (2.0.5) lib/rack/etag.rb:25:in `call'
rack (2.0.5) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.5) lib/rack/head.rb:12:in `call'
activerecord (5.2.1) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.1) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.1) lib/rails/rack/logger.rb:26:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.1) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
railties (5.2.1) lib/rails/engine.rb:524:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
I don't understand why not work because I follow all the steps of the oficial guide https://guides.rubyonrails.org/action_mailer_basics.html

Resources