Mailboxer を使用してユーザーに通知を送信しようとしていますが、navbar の通知ドロップダウンに通知がどのように表示されるかに影響するオブジェクトを渡す必要があります。
@recipient.notify("#{current_user.name} needs you to review his help with: #{@offer.title}", "#{@message}", @offer)
最後の引数は、オブジェクトを渡そうとしているところです@offer
。
これは、私が使用しようとしている Mailboxer メソッドです。
def notify(subject,body,obj = nil,sanitize_text=true,notification_code=nil,send_mail=true)
Mailboxer::Notification.notify_all([self],subject,body,obj,sanitize_text,notification_code,send_mail)
end
このnotify_all
メソッドを呼び出します。
def notify_all(recipients, subject, body, obj = nil, sanitize_text = true, notification_code=nil, send_mail=true)
notification = Mailboxer::NotificationBuilder.new({
:recipients => recipients,
:subject => subject,
:body => body,
:notified_object => obj,
:notification_code => notification_code
}).build
notification.deliver sanitize_text, send_mail
end
this: でオブジェクトにアクセスしようとすると<%= notification.object_id %>
、 のような長い数値が返され205981093
ます。offer
これでオブジェクトのフィールドの1 つにアクセスしようとすると、エラーが発生します。<%= notification.object_id.title %>
`undefined method `title' for 2166878920:Fixnum`
これが Mailboxer Notifications の使用方法であるかどうかさえわかりません。それらに関する情報を見つけるのに非常に苦労しました。どんな助けでも大歓迎です。