calling custom validation methods in Rails

前端 未结 3 1882
离开以前
离开以前 2021-01-30 06:42

I just upgraded my rails to 2.3.4 and I noticed this with validations: Lets say I have a simple model Company which has a name. nothing to it. I want to run my own validation:<

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 06:59

    Just FYI errors.add_to_base('error message') has been deprecated in rails 3 and got replaced by

    errors[:base] << "Error message" 
    

    Or

    errors.add(:base, "Error message")
    

提交回复
热议问题