error_messages_for 在 ruby 中已弃用 - 如何找到替代品? [英] error_messages_for is deprecated in ruby - how do I find the replacement?
问题描述
我正在阅读一本旧书(2008 年)来学习 ruby,它适用于 rails 2.0.2.
I am reading an old book (2008) to learn ruby and it is for rails 2.0.2.
我决定使用 Rails 3 来找出当时的 ruby 与现在的区别.到目前为止,大部分内容都很好,我很容易找到并纠正差异.
I have decided to use Rails 3 to find out the differences between the ruby back then to what it is now. Most of it has been good so far and I have been easily been able to find and correct the differences.
我现在遇到的问题是代码使用了不推荐使用的函数 error_messages_for
并查看 http://apidock.com/rails/ActionView/Helpers/ActiveRecordHelper/error_messages_for 我找不到替代品或任何方式来告诉我什么是新方式.有人可以帮助我找到使用 error_messages_for
的新方法,以及我应该如何寻找新的做事方法和发现新的最佳实践的方法等.
The problem I am having now, is that the code is using a deprecated function error_messages_for
and upon looking at http://apidock.com/rails/ActionView/Helpers/ActiveRecordHelper/error_messages_for I cannot find a replacement or any way to show me what the new way is. Can someone help me find the new way to use error_messages_for
and how I should go about finding the new way to do things and the way to discover the new best practices etc.
推荐答案
- Rails 3.0 中的 f.error_messages
- Rails error_messages 助手
- http://www.emersonlackey.com/article/rails3-错误消息替换
- http://ariejan.net/2010/12/15/why-did-errormessagesfor-disappear-from-rails-3/
- https://gist.github.com/1113828
仅在 Google 搜索rails error_messages_for rails 3"时找到的前 5 个链接.
Just the top 5 links found searching Google for "rails error_messages_for rails 3".
也就是说,您确实应该使用最新的书.即使是最新的免费 Rails 教程也涵盖了 Rails 3.
That said, you really should use an up-to-date book. Even the latest free Rails tutorials are covering Rails 3.
这篇关于error_messages_for 在 ruby 中已弃用 - 如何找到替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!