backbone.js 和处理来自 Rails 的错误消息?
我想知道backbone.js 用户是否可以帮助我?
与backbone.js一起使用时,对来自rails应用程序的错误消息进行编码的最佳方法是什么,例如那些曾经定义为闪存消息的错误消息,例如“未找到记录”。
大多数情况下,错误可以在客户端中定义,但是,有时您希望传递在服务器端代码中定义的错误,这意味着服务器的结果与正常接收记录列表的预期结果不同一个集合。
I wonder if backbone.js users could please help me?
What is the best way to encode error messages from a rails app when used with backbone.js for example those error messages that were once defined as flash messages eg "record not found".
Most of the time errors can be defined in the client, however, sometimes you want to pass a error that you have defined in the server side code, which means the result from the server is different than expected from normally receiving a list of records into a collection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将 Rails 控制器设置为:
respond_to :json
您将收到 json 形式的错误(您需要使用 respond_with(object) )
我创建了 json 响应器以更好地处理主干:
If you set your rails controller as:
respond_to :json
You will receive your errors as json (you need to use respond_with(object) )
I created my json responder to better deal with backbone: