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

On 15 May 2008, at 10:04, [email protected] wrote:

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?

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

On 15 Mai, 11:04, “[email protected]

On 15 Mai, 11:21, “[email protected]
[email protected] wrote:

Fred

i tested both things but nothing works.

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

On May 15, 11:14 am, Frederick C. [email protected]
wrote:

end

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

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

i tested both things but nothing works.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs