Ruby 如何解决UsersController中的Errno::ECONNREFUSED#在ROR中创建错误

Ruby 如何解决UsersController中的Errno::ECONNREFUSED#在ROR中创建错误,ruby,ruby-on-rails-3,email,ruby-on-rails-4,Ruby,Ruby On Rails 3,Email,Ruby On Rails 4,有人能帮我解决以下错误吗?我正试图发送一封电子邮件,但发送失败并引发一些错误 错误: Errno::在UsersController#create中重新融合 无法建立连接,因为目标计算机主动拒绝了它。-连接(2) app/controllers/users\u controller.rb:8:in'create' 下面给出了我的代码片段 views/users/index.html.erb <h1>Send email to your friend</h1> <%=

有人能帮我解决以下错误吗?我正试图发送一封电子邮件,但发送失败并引发一些错误

错误:

Errno::在UsersController#create中重新融合 无法建立连接,因为目标计算机主动拒绝了它。-连接(2) app/controllers/users\u controller.rb:8:in'create'

下面给出了我的代码片段

views/users/index.html.erb

<h1>Send email to your friend</h1>
<%= form_for @user,:url => {:action => 'create'} do |f| %>
    <%= f.text_field:name,placeholder:"Enter your name" %><br>
    <%= f.email_field:email,placeholder:"Enter your email" %><br>
    <%= f.submit "Send" %>
<% end %> 
development.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = true

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
  config.action_mailer.delivery_method = :smtp


  end
routes.rb

Rails.application.routes.draw do
 root 'users#index'
  post "users/create" => "users#create"
 get "users/success" => "users#success"
  get "users/new" => "users#new"
end

实际上我是指这个。我使用的是rails-4和ruby 1.9.3。请帮助我解决这个错误。

检查谷歌的action\u mailer设置。可能是你错过了域名。例如,我们的生产设置包括以下设置:域(example@gmail.com),用户名(示例),密码。
class UsersController < ApplicationController
  def index
    @user=User.new
  end
  def create
    @user=User.new(users_params)
    if @user.save
      UserMailer.registration_confirmation(@user).deliver
      redirect_to :action => 'success'
    else
      render :'index'
    end
  end
  def new

  end
  def success

  end
  private
  def users_params
    params.require(:user).permit(:name, :email)
  end
end
<%= @user.name%>
<h1>Thank you for registering</h1>
Click <%= link_to "here",users_new_path %>
class UserMailer < ApplicationMailer
  default :from => "w5call.w5rtc@gmail.com"
  def registration_confirmation(user)
    @user=user
    mail(:to => user.email, :subject => "Registered")
  end
end
config.action_mailer.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :user_name            => "w5call.w5rtc@gmail.com",
    :password             => "w5rtc123@",
    :authentication       => "plain",
    :enable_starttls_auto => true
}

endActionMailer::Base.default_url_options[:host] = "localhost:3000"
Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = true

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
  config.action_mailer.delivery_method = :smtp


  end
Rails.application.routes.draw do
 root 'users#index'
  post "users/create" => "users#create"
 get "users/success" => "users#success"
  get "users/new" => "users#new"
end