alexBoSmallblind-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-May-15 09:04 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 15 May 2008, at 10:04, alexBoSmallblind-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, try using ''entry.field.blank?'' instead of ''entry.field.nil?''. Falk Köppe On 15 Mai, 11:04, "alexBoSmallbl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" <alexan...-ad560ng7LD/IJoCZWJrliQ@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
alexBoSmallblind-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-May-15 09:21 UTC
Re: Observer don''t check if condition
On May 15, 11:14 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 15 May 2008, at 10:04, alexBoSmallbl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org 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 > > Fredi tested both things but nothing works. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
alexBoSmallblind-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-May-15 09:33 UTC
Re: Observer don''t check if condition
On 15 Mai, 11:21, "alexBoSmallbl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" <alexan...-ad560ng7LD/IJoCZWJrliQ@public.gmane.org> wrote:> On May 15, 11:14 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On 15 May 2008, at 10:04, alexBoSmallbl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org 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 > > i tested both things but nothing works.DAMN it. it works, mistake by me !! Thanks for all your help --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---