Posts

Showing posts with the label model validation

Rails mongoid has field model validation

This can be done only with a custom method validation, Such as           class Comment        include Mongoid::Document        include Mongoid::Timestamps         include ActiveModel::Validations              validate :must_be_friends              def must_be_friends           errors.add(:base, 'Must be friends to leave a comment') if hash[:firstname].nil?        end     end