ActiveModel验证忽略语言环境翻译

时间:2018-08-01 14:28:24

标签: ruby-on-rails translation activemodel

我上了这个课:

from math import atan2,degrees
line = #Your-LineString-Object
lineList = list(line.coords)

def AngleBtw2Points(pointA, pointB):
  changeInX = pointB[0] - pointA[0]
  changeInY = pointB[1] - pointA[1]
  return degrees(atan2(changeInY,changeInX)) #remove degrees if you want your answer in radians

AngleBtw2Points(lineList[0],lineList[1]) 

还有一个显示验证错误的表单,如下所示:

enter image description here

enter image description here

我希望它使用“密码确认”代替属性名称。因此,我尝试在class Password < BaseModel request_body_type :json attr_accessor :password, :password_confirmation include ActiveModel::Validations #password only: validates_presence_of :password validates_presence_of :password_confirmation validates_confirmation_of :password end 文件上进行设置:

en.yml

但这不起作用。

en: activerecord: attributes: password: password_confirmation: "Password confirmation" 的{​​{3}}知道,我可以设置自定义消息(默认为validates_confirmation_of),但是此消息仍在开头使用属性名称。

如果我运行Rails控制台并执行“doesn’t match %{translated_attribute_name}",它将打印配置文件上显示的值:Password.human_attribute_name('password_confirmation')

有什么想法吗?

0 个答案:

没有答案