Reputation: 10744
I have in invitation_mailer.rb the next:
class InvitationMailer < ActionMailer::Base
default :from => "[email protected]"
def invitation_friends(invitation, user)
@user = user
@invitation = invitation
mail(:bcc => @invitation.recipients.map(&:recipients), :subject => "Subject email")
end
end
@invitation.recipients is an array with emails like:
["[email protected]","[email protected]"]
but I get in log the next:
NoMethodError (undefined method `recipients' for "[email protected]":String):
What am I doing wrong?
Thank you!
Upvotes: 1
Views: 5574
Reputation: 5880
I believe this line:
@invitation.recipients.map(&:recipients)
should actually be:
@invitation.recipients.join(';')
map(&:recipients)
means: call #recipients method on each element in the array. You get he error since your array holds strings, and clearly String doesn't have method #recipients :)
Upvotes: 1
Reputation: 330
Try @invitations.recipients.join("; ")
You are trying to call :recipients on a String-object in your array, which cannot work.
Upvotes: 5