OK, Rails noob đặt một câu hỏi. Tôi đang cố gắng làm Rails lần đầu tiên ở đây. Tôi đang đọc Agile Web Dev với Rails 4th ed. Tôi nhận được lỗi này trên hộp sản xuất của tôi. này hoạt động trong chế độ phát triển dưới webrick, tôi nhận được một email gửi đến acount gmail của tôi và evrything nhưng trên hộp apache của tôi trong chế độ sản xuất, tôi nhận được lỗi này ...Errno :: ECONNREFUSED trong OrdersController # create
Errno::ECONNREFUSED in OrdersController#create
Connection refused - connect(2)
Application dấu vết là ...
app/controllers/orders_controller.rb:58:in `create'
app/controllers/orders_controller.rb:54:in `create'
và đây là def tạo trong app/controllers/order_controller.rb
def create
@order = Order.new(params[:order])
@order.add_line_items_from_cart(current_cart)
respond_to do |format| #THIS IS LINE 54
if @order.save
Cart.destroy(session[:cart_id])
session[:cart_id] = nil
Notifier.order_received(@order).deliver #THIS IS LINE 58
format.html { redirect_to(store_url, :notice => I18n.t('.thanks')) }
format.xml { render :xml => @order, :status => :created, :location => @order }
else
format.html { render :action => "new" }
format.xml { render :xml => @order.errors, :status => :unprocessable_entity }
end
end
có gì sai với dòng của tôi 58 và 54? Điều này có liên quan đến cài đặt action_mailer của tôi trong app/config/environment.rb không?
Đây là environment.rb
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Depot::Application.initialize!
#uncertain about anything below this line
Depot::Application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => "plain",
:user_name => "[email protected]",
:password => "<password>",
:enable_starttls_auto => true
}
end
Any help is appreciated. Cảm ơn.
Có vẻ như ứng dụng của bạn không thể kết nối với gmail vì một số lý do. Có lẽ xem xét sử dụng một dịch vụ thay thế như [SendGrid] (http://sendgrid.com) –
Không có gì sai với dòng 54, nó chỉ là điểm vào cho khối mã đó. Nếu bạn bình luận ra dòng 58 thì ngoại lệ có biến mất không? Thậm chí tốt hơn hãy thử sử dụng [debugger] (http://www.themomorohoax.com/2009/02/09/use-debugger). –
nhận xét tiêu cực ngoài dòng 58 không thay đổi mọi thứ. – thefonso