我有一个名为'视频'的模型
在该模型中,有一个video_cid,用于验证状态。
在表单中,这是一个隐藏字段,当有人录制视频时,该字段会更新为某个值。
目前,当用户未保存视频时,我能够生成错误消息==>
Video can't be blank
有没有办法可以完全改变这句话?我想说 - >
It looks like the video has not been saved. Please record and save your video.
我可以使用locales / en.yml文件将Video Cid的名称更改为“Video”
这是我的视频模型:
# == Schema Information
#
# Table name: videos
#
# id :integer not null, primary key
# user_id :integer
# video_cid :string(255)
# question :string(255)
# created_at :datetime
# updated_at :datetime
#
class Video < ActiveRecord::Base
belongs_to :user
validates :user_id, presence: true
validates :question, presence: true
validates :video_cid, presence: true
end
这是我的locales / en.yml文件:
en:
activerecord:
attributes:
video:
video_cid: "Video"
答案 0 :(得分:1)
试试这个
validates :video_cid, :presence => {:message => "It looks like the video has not been saved. Please record and save your video."}