Reputation: 3449
I am practicing ROR4 with the Pragmatic Agile Rails development book. In it, there's a section about sending email via ActionMailer. Although I am able to send email, I am unable to remove the eppended Rails object, as shown below, in the highlighted area:
(
LineItem
is a model, used to store quantity of Product
that buyer puts in Cart
)
// 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>
Can Someone please tell me, why is the LineItem
thing showing up in the final email?
Upvotes: 2
Views: 175
Reputation: 2170
In your ERB file, remove the =
sign from the @order.line_items.each
:
<% @order.line_items.each do |o_li| %>
That will cause the model object to be printed in addition to the block executing.
Upvotes: 4