如何在弹出窗口中获取设备错误消息
我正在使用 jquery 将 devise 的注册表单作为弹出窗口加载。问题是我无法在弹出窗口中加载设备的错误消息。
如果我单击空注册表单,我将被重定向到另一个页面,在其中看到错误消息。
我已经浏览了 devise 的 github 帖子,但找不到我正在寻找的解决方案。
我在应用程序帮助程序中创建了一个方法,以便 <%= devise_error_messages! %>
表单助手中的代码工作正常。
应用程序帮助程序代码如下:-
def devise_error_messages!
resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
end
我知道这有问题,但无法弄清楚是什么。谁能帮我解决这个问题吗?
更新
我认为,由于当我点击提交按钮时弹出框中没有显示错误,因此注册控制器的创建操作可能存在问题。将尝试覆盖设备注册控制器的默认创建操作。让我们看看它是否适用于这些更改。
更新2
进行了我在上面的更新中提到的更改,尽管它不起作用,但它给人一种感觉,我非常接近解决方案:)
仍在等待一些帮助。
谢谢,
I am using jquery to load the signup form of devise as a popup. The problem is the I am not able to load the error messages of the devise in the popup.
If I click on the empty signup form I am redirected to the another page where I see the error message.
I have gone through the github posts of devise but could not find the solution which I am looking for.
I have created a method in the application helper so that the <%= devise_error_messages! %>
code in the form helper works properly.
The application helper code is as follows :-
def devise_error_messages!
resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
end
I know that something is wrong with this but cannot figure out what. Can anyone please help me out with this one.
UPDATE
I think that since the errors are not showing in the pop up box when I hit the submit button, there might be an issue with the registration controller's create action. Will try to override the default create action of the registration controller of devise. Lets see if it works with these change.
UPDATE 2
Made the changes which I mentioned in the update above although it is not working it gives a feeler that I am very close to the solution :)
Still waiting for some help.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否覆盖 RegistrationsController 的创建操作?如果resource.save失败,那应该可以解决问题,你可以
只将错误消息返回给你的jquery脚本。例如:
Are you overriding the create action of the RegistrationsController? That should do the trick if resource.save fails you could just
that should hand just the error messages back to your jquery script. For example: