2012-03-02 16 views
1

actionmailerの複数の受信者に電子メールを送信:invitation.recipients @私は<strong></strong> invitation_mailer.rb次に持って

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 

のような電子メールを持つ配列である:

["[email protected]","[email protected]"] 

が、私が得ます次のログ:

NoMethodError (undefined method `recipients' for "[email protected]":String): 

私は何が間違っていますか?

ありがとうございました!働くことができないあなたの配列のStringオブジェクトの受信者を、:

+0

問題は修正されました。修正は '@invitation.recipients.map {| val | p val} 'ありがとうございました – hyperrjas

答えて

5

は、あなたが呼び出すためにしようとしている@invitations.recipients.join("; ")

を試してみてください。

@invitation.recipients.map(&:recipients) 

実際にする必要があります:私は、この行が信じる

1

@invitation.recipients.join(';') 

map(&:recipients)は意味:配列の各要素に#recipientsメソッドを呼び出します。あなたの配列は文字列を保持しているのでエラーになります。文字列にはメソッド#recipientsがありません。

関連する問題