您好,我是 ruby on rails 的新手,我在验证旧密码时遇到问题。如果我要进入编辑帐户页面并且如果我保存旧密码验证显示即使编辑帐户页面和更改密码页面是不同的页面但它们在一个模型中共享。请帮助我。
这是我的模型:
validates_presence_of :firstname, :message => 'First Name is required'
validates_format_of :firstname, :with => /\A[a-zA-Z]+([a-zA-Z]|\d)*\Z/, :message => 'First name must not contain special characters'
validates_presence_of :lastname, :message => 'Last Name is required'
validates_format_of :lastname, :with => /\A[a-zA-Z]+([a-zA-Z]|\d)*\Z/, :message => 'Lastname name must not contain special characters'
validates_presence_of :email, :message => 'Email Address is required'
validates_uniqueness_of :email, :message => 'Email address is already taken, please select a new one'
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Please enter a valid email address"
validates_presence_of :username, :message => 'Username is required'
validates_uniqueness_of :username, :message => 'Username is already taken, please select a new one'
validates_length_of :username, :within => 3..15, :message => "Username must be at least 3 - 15 characters in length", :on => :create
validates_presence_of :password_old, :on => :update, :message => "Old password is required"
如果您需要更多信息,请发表评论....提前致谢。