Tag: VALIDATION
-
Rails Validating Field vs Association
One really interesting thing I came across recently is validating a field vs association. I’ve always written something like this (assume this is a… Company model with a attribute called owner_id and a belongs_to association called owner): What’s better to write is: This actually makes sure that your :owner_id actually maps to a real object in the database.…