2016-10-19 2 views
0

각 거래 후에 상점 주인에게 메일을 보내려고합니다. 다른 모든 것은 설정되어 있지만 생성 된 이메일 주소를 얻을 수없는 것 같습니다. cart_id, LINE_ITEM_ID, PRODUCT_TITLE : 페이팔에서Mailer Challenge with Rails

class PaymentNotifier < ActionMailer::Base 

def notify(payment_notification) 
    @payment_notification = payment_notification 
    mail to: **'xxxxxxxxx'**, subject: 'New order' 
    end 
end 

지불 통지는 트랜잭션의 세부 시스템에 제공됩니다.

Line_item에는 cart_id 열과 product_id 열이 있습니다.

제품에 store_id 열이 있습니다.

스토어에는 user_id 열이 있습니다.

사용자는 의 이메일 주소입니다.

내 메일러에서이 이메일 주소에 액세스하여 거래 후 이메일을 수신하는 방법을 찾으려합니다.

도움을 주시면 감사하겠습니다.

미리 감사드립니다.

+0

를 사용하고, 같은 user_email,

LineItem.find(@payment_notification.line_item_id).product.store.user.email 

우편을받을 수 있나요? – Sravan

+1

@Sravan 예, 있습니다. 왜? –

답변

1

당신의 연결을 참조하면, 당신은 당신이 고안

class PaymentNotifier < ActionMailer::Base 

def notify(payment_notification) 
    @payment_notification = payment_notification 
    mail to: LineItem.find(@payment_notification.line_item_id).product.store.user.email, subject: 'New order' 
    end 
end 
+0

'current_user.email'을 사용하면 로그인 한 사용자에게 보내지 않겠습니까? –

+0

하지만 전자 메일은 상점 주인에게 가야한다고 말했습니까? – Sravan

+0

메일을 logged_in 사용자에게 보내려면'current_user.email'을 사용하면되지만, 저장소 소유자에게 보내고 싶다면 내 대답을 확인하십시오. – Sravan