您好,我正在阅读使用 Rails 第 4 版进行敏捷 Web 开发,但在“任务 H:发送邮件”时出现错误
我有邮件order_notifier.rb
class OrderNotifier < ActionMailer::Base
default :from => "name@email.tld"
def received
@order = order
mail(:to => order.email, :subject => 'Pragmatic Store Order Confirmation')
end
def shipped
@order = order
mail(:to => order.email, :subject => 'Pragmatic Store Order Shipped')
end
end
我有模板/views/order_notifier/收到.text.erb 并发送.text.erb 之类的
Dear <%= @order.name %>
Thank you for your recent order from The Pragmatic Store.
You ordered the following items:
<%= render @order.line_items %>
We'll send you a separate e-mail when your order ships.
我从OrdersController运行它 我不确定是使用 current_cart 还是 @cart 但我想没关系
def create
@order = Order.new(params[:order])
@order.add_line_items_from_cart(current_cart)
#@order.add_line_items_from_cart(@cart)
respond_to do |format|
if @order.save
Cart.destroy(session[:cart_id])
session[:cart_id] = nil
OrderNotifier.received(@order).deliver
我得到的错误告诉我,收到的方法有一个参数比它需要的多(@order),但这就是它在书中的写法..错误:
ArgumentError in OrdersController#create
wrong number of arguments (1 for 0)
错误在哪里?谢谢你。