为什么 Rails 没有“errors.full_messages"?替换属性和消息变量? [英] Why doesn't Rails' "errors.full_messages" replace attribute and message variables?
问题描述
我刚刚创建的 Rails 模型有一个奇怪的问题.
Having a strange problem with a rails model I just created.
这是我的验证:
validates_presence_of :from_name, :message => 'Please provide a from name.'
validates_presence_of :from_email
validates_presence_of :giftition_plan_id
我在表单中使用 errors.full_messages
和 f.error_messages
时遇到问题:
I'm having issues using errors.full_messages
as well as f.error_messages
in my form:
g = Giftition.create
g.errors.first
=> ["from_name", "Please provide a from name."]
>> g.errors.full_messages
=> ["{{attribute}} {{message}}", "{{attribute}} {{message}}", "{{attribute}} {{message}}"]
我刚刚收到 "{{attribute}} {{message}}"
.有什么想法吗?
I'm just getting "{{attribute}} {{message}}"
. Any ideas?
更新:我已经卸载了 rails 3 和所有与它一起安装的 gem,这让问题消失了.但这不是解决办法……我仍然希望安装 rails 3.
UPDATE: I've uninstalled rails 3 and all the gems that were installed with it and that made the problem go away. It's not a fix though... I would still like to have rails 3 installed.
更新:听起来升级到 2.3.9 可以解决问题.不幸的是,我现在已经放弃了,但将来某个时候我会尝试的.
UPDATE: Sounds like upgrading to 2.3.9 fixes the problem. Unfortunately, I've given up for now, but sometime in the future I will try that.
推荐答案
升级到版本 rails 2.3.9 修复了这个问题
Upgrading to Version rails 2.3.9 fixes this problem
gem install -v 2.3.9 rails --include-dependencies
您还需要编辑 configenvironment.rb
文件以更改 RAILS_GEM_VERSION
.
You also need to edit the configenvironment.rb
file to change the RAILS_GEM_VERSION
.
RAILS_GEM_VERSION = '2.3.9'
编辑#2:
请注意,2.3.9 版本不是 2.3.X 分支的最新版本,您应该升级可用的最新版本.
I should note that version 2.3.9 is not the latest version of the 2.3.X branch, and you should upgrade the the latest version available.
这篇关于为什么 Rails 没有“errors.full_messages"?替换属性和消息变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!