Undefined local variable or method “rendering_options” error for

huangapple go评论57阅读模式
英文:

Undefined local variable or method "rendering_options" error for

问题

我是一名初学者,我在以前的项目中使用了这个修复(https://medium.com/@nejdetkadir/how-to-use-devise-gem-with-ruby-on-rails-7-33b89f9a9c13)来使devise与turbo表单配合使用,它运行正常。但是当我在我的新项目中使用它时,当我注册时没有填写任何字段(或在任何表单字段中传递无效信息)时,它会给我一个错误,错误消息如下:

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=null>

参考以下是我的:

devise控制器文件:https://pastebin.pl/view/d275fa93

devise rb文件:https://pastebin.pl/view/1b80a0bb

控制台输出:https://pastebin.pl/view/abee4b18

错误截图:https://paste.pics/49220ee8d4a60bd874f539e689b32c07, https://paste.pics/286c88869865db2e996ce039a3d5eac3

英文:

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

答案1

得分: 2

将以下部分翻译为中文:

"我在偶然发现的这篇日文文章中也遇到了与这个确切问题的斗争:https://qiita.com/gazayas/items/0726f9ffa093e4e2d772

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

更改为

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

对我来说解决了这个问题。显然,这是由于响应器更新到3.1.0版本引起的。"

英文:

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.

huangapple
  • 本文由 发表于 2023年2月8日 15:41:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75382636.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定