formsdeviseruby-on-rails-7turbo-rails

Undefined local variable or method "rendering_options" error for


I am a beginner and I have used this fix (https://medium.com/@nejdetkadir/how-to-use-devise-gem-with-ruby-on-rails-7-33b89f9a9c13) for making devise work with turbo forms in my previous project and it worked fine. But when I use it in my new project it gives me an

undefined local variable or method rendering_options' for #<TurboDeviseController::Responder:0x00007f9684019cb8 @controller=#<Devise::RegistrationsController:0x0000000000bbd0>, @request=#<ActionDispatch::Request POST "http://localhost:3000/users" for ::1>, @format=:turbo_stream, @resource=#<User id: nil, email: "", created_at: nil, updated_at: nil>, @resources=[#<User id: nil, email: "", created_at: nil, updated_at: nil>], @options={}, @action=:new, @default_response=nil>

error when I sign-up without filling any fields(or passing invalid info in any of the form fields). My previous project seems to be working just fine and I have recreated this error three separate times just to be sure.

For reference here are my:

devise controller file: https://pastebin.pl/view/d275fa93

devise rb file: https://pastebin.pl/view/1b80a0bb

console output : https://pastebin.pl/view/abee4b18

screenshots of error: https://paste.pics/49220ee8d4a60bd874f539e689b32c07, https://paste.pics/286c88869865db2e996ce039a3d5eac3


Solution

  • I was also struggling with this exact problem when I stumbled upon this article written in Japanese: https://qiita.com/gazayas/items/0726f9ffa093e4e2d772

    Changing

    render rendering_options.merge(formats: :html, status: :unprocessable_entity)
    

    to

    render error_rendering_options.merge(formats: :html, status: :unprocessable_entity)
    

    fixed the problem for me. Apparently it is caused by responders updating to 3.1.0.