2
Pragmatic Agile Rails 개발 안내서에서 ROR4를 실습 중입니다. 여기에는 ActionMailer를 통해 이메일을 보내는 방법에 대한 섹션이 있습니다. 나는 이메일을 보낼 수 있어요하지만 강조 표시된 영역에서 다음과 같이 나는 eppended 레일 개체를 제거 할 수없는입니다 : ActionMailer를 통해 전자 메일에 표시된 레일스 객체가 표시되는 이유
LineItem
그 구매자가
Cart
에두고
Product
의 저장 수량에 사용되는 모델입니다)
이 내 파일의 내용은 다음과 같습니다
// order_notifier.rb = my email sender model
class OrderNotifier < ActionMailer::Base
default from: "[email protected]"
def received(order)
@order=order
mail to: @order.email, subject: 'Pragmatic Store Order Confirmation'
end
def shipped
mail to: "[email protected]"
end
end
// recieved.html.erb = the mail that will be sent
<h3>PragmaticOrderShipped</h3>
<p>This is just to let you know that we've shipped your recent order:</p>
<table>
<tr>
<th>Description</th>
<th>Qty</th>
</tr>
<%[email protected]_items.each do |o_li|%>
<tr>
<td><%=Product.find(o_li.product_id).title%></td>
<td><%=o_li.quantity%></td>
</tr>
<%end%>
</table>
누군가가 왜 LineItem
것은 최종 이메일에 표시됩니다 말해 주시겠습니까? 당신의 ERB 파일에서
도 변경할 수'
@ DanFairaizl - thankx. 그 트릭을했다. – zhirzh
@NitinVerma - 예. 나는 그 제품이 속한 질문을하는 순간을 잊었다. line_items. 바보 나. – zhirzh