Friday, October 19, 2007

Validate field that doesn't exist in the table

In order to validate such a field like this in Rails, you must create a virtual attribute in the model and then use a normal validation routine in the model.

validates_presence_of : house_number
def house_number
@house
end
def house_number=(house_number)
@house = house_number
end


Otherwise, you have to manually validate by yourself.

No comments:

Subscribe in a Reader