Yes, you can check it with #present? One note though -- you probably don't need an attribute setter for `alternate_approval_email` if all it does is return the username with appended domain information:
def alternate_approval_email alternate_approval_username + "@sandiego.gov" if alternate_approval_username.present? end On Tue, Nov 27, 2012 at 9:18 AM, KT <[email protected]> wrote: > Sweet - thank you. > > I forgot that I have a method in my invoice model to append the email > address to the alternate_approver_username. How do I ignore that method if > alternate_approver_username is null? Do I use: if > alternate_approver_username.present? > > *def alternate_approver_email > self.alternate_approver_email = self.alternate_approver_username + "@ > sandiego.gov" > end* > > > On Tuesday, November 27, 2012 9:13:54 AM UTC-8, James Miller wrote: > >> @recipients = [invoice.approver_email, invoice.alternate_approver_** >> email].compact >> >> >> On Tue, Nov 27, 2012 at 9:06 AM, KT <[email protected]> wrote: >> >>> I have a Rails 3 app sending emails to multiple (2) recipients. The >>> first recipient is required, but the second is not required. I get an error >>> if the second recipient is null. How do I bypass the secondary email if >>> null without getting an error? >>> >>> def email_approvers(invoice) >>> @subject = 'Invoice Approval Request' >>> @body["invoice"] = invoice >>> @recipients = invoice.approver_email, >>> invoice.alternate_approver_**email >>> @from = "..." >>> @sent_on = Time.now >>> @headers = {} >>> end >>> >>> Thanks for your help!! >>> >>> -- >>> SD Ruby mailing list >>> [email protected] >>> http://groups.google.com/**group/sdruby<http://groups.google.com/group/sdruby> >> >> >> -- > SD Ruby mailing list > [email protected] > http://groups.google.com/group/sdruby > -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
