I have a simple model called PhoneNumber:
class PhoneNumber < ActiveRecord::Base
validates :pnumber, presence: true, on: :create #=> { :message =>
If none of the above work, I also have a different approach, as it happened to me in a real scenario.
More specifically using auto-generated Ruby files from Thrift.
In my situation, I had a Module with several classes, so the order is important in this case:
Class A makes use of Class B in the same module. However, Class B was declared after Class A.
Simply making Class B to be declared before Class A solved the issue to me.