Railsvalidation错误消息显示错误消息和数组
我正在完成Ruby-on-Rails3教程第8章。
我创建了一个用户提交注册站点的表单。
validation在模型中设置。 它们已经过测试并正在运行。
问题是,当我显示validation错误消息时,执行以下操作:
prohibited this user from being saved:
There were problems with the following fields:
我不仅获得了validation消息,而且还显示了实际的数组:
2 errors prohibited this user from being saved: There were problems with the following fields: Password can't be blank Password is too short (minimum is 6 characters) **["Password can't be blank", "Password is too short (minimum is 6 characters)"]**
对于我的生活,我无法弄清楚为什么。 任何人都知道如何阻止这种显示?
提前致谢。
这是Rails3.0.7 Ruby 1.9.2 OSX10.6
<%= @user.errors.full_messages.each do |message| %> <%= message %>
使用此行<%= @user.errors.full_messages.each do |message| %>
打印数组 <%= @user.errors.full_messages.each do |message| %>
delete =
从中。
我用的很糟糕
<%=@user.errors.full_messages.each do |message|%>
代替
<% @user.errors.full_messages.each do |message|
- Rails教程 – 9.3.3 Current_User
- 缺少必需的参数:ras测试中的aws_access_key_id,aws_secret_access_key
- Hartl Ruby on Rails教程4 ch 10,用户编辑测试失败
- 在Hartl的rails教程的步骤5.1.2中,bootstrap-sass gem破坏了我的轨道3.2.3
- Ruby on Rails Michael Hartl第8.5章测试失败
- 为什么carrierwave导致NameError:未初始化的常量Micropost :: PictureUploader错误?
- 如何在部署到heroku时解决rails中的更新捆绑器警告?
- 如何保持rspec测试DRY有很多“have_link”
- 为什么我的RSpec测试失败,但我的应用程序正在运行?