【发布时间】:2010-12-07 03:24:00
【问题描述】:
我是 Rails 的新手,今天我使用 validate 制作了我的第一个 Web 应用程序,我只是将这行代码放入模型中:
class ClientWorkout < ActiveRecord::Base
validates_numericality_of :paid_amount
validates_presence_of :client_name
end
这是视图部分:
<% form_for(@client_workout) do |f| %>
<%= f.error_messages %>
etc etc
一切正常,并且值存储在数据库中,在成功的情况下
{{count}} errors prohibited this {{model}} from being saved
There were problems with the following fields:
{{attribute}} {{message}}
{{attribute}} {{message}}
(该示例显示了当表单的 2 个参数错误时发生的情况,但在每种情况下都会发生这种情况)
它无法将“计数、模型、属性和消息”替换为实际值。
任何人都可以弄清楚发生了什么?
我使用 Ror 2.3.8 和 rails 1.8.7
【问题讨论】:
标签: ruby-on-rails forms validation