Observer don't check if condition

Hi,
i have a problem with the mail deliver after a entry is save.
I want to check if one field is filled. In every Option (Controller
action, model, observer) i wrote a

if !entry.field.nil?
Mail.deliver_entry(entry)
end

But i get this mail also if the entry field is nil.

I also wrote a EntryObserver which implements the following method

def after_save(entry)
Mail.deliver_entry(entry) if !entry.field.nil?
end

can anybody tell me, why this doesn't work for me?

thanks alex

I suspect what is happening is that entry.field is the empty string (which is of course not nil). .blank? checks for both nil and the empty string

Fred

Hi,

try using 'entry.field.blank?' instead of 'entry.field.nil?'.

Falk Köppe

i tested both things but nothing works.

DAMN it. it works, mistake by me !! Thanks for all your help