Попытка реализовать Регистрацию в Rails, но выполнение истекает при отправке формы - PullRequest
1 голос
/ 12 февраля 2011

Это ошибка, которую я вижу:

Timeout::Error in Devise/registrationsController#create

execution expired

Вот как выглядит мой файл development.rb:

 MyApp::Application.configure do
  # Settings specified here will take precedence over those in config/environment.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 webserver when you make code changes.
  config.cache_classes = false

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_view.debug_rjs             = 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

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin


  config.action_mailer.default_url_options = { :host => 'localhost:3000' } #Make sure to set 'host' to domain name in production.  
  config.action_mailer.delivery_method = :smtp
     config.action_mailer.perform_deliveries = false
     config.action_mailer.raise_delivery_errors = true
     config.action_mailer.default :charset => "utf-8"

end

Я проверяю свои логи, вот что я вижу, как только я нажимаю кнопку «Отправить» в регистрационной форме:

Started GET "/users/register" for 127.0.0.1 at 2011-02-11 19:19:23 -0500
  Processing by Devise::RegistrationsController#new as HTML
nil
Rendered devise/shared/_links.erb (2.4ms)
Rendered devise/registrations/new.html.erb within layouts/application (98.1ms)
Completed 200 OK in 160ms (Views: 109.0ms | ActiveRecord: 0.0ms)


Started POST "/users" for 127.0.0.1 at 2011-02-11 19:20:03 -0500
  Processing by Devise::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"qWs4IOH3L+GT/Sld8rZRlhXi8JM0pe0NtWG4Tn9XRIU=", "user"=>{"username"=>"marcamillion", "f_name"=>"marc", "l_name"=>"gayle", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "email"=>"marc@amillion.com"}, "commit"=>"Register"}
nil
WARNING: Can't mass-assign protected attributes: f_name, l_name
  User Load (0.2ms)  SELECT "users"."id" FROM "users" WHERE (LOWER("users"."email") = LOWER('marc@amillion.com')) LIMIT 1
  User Load (0.1ms)  SELECT "users"."id" FROM "users" WHERE (LOWER("users"."username") = LOWER('marcamillion')) LIMIT 1
  CACHE (0.0ms)  SELECT "users"."id" FROM "users" WHERE (LOWER("users"."email") = LOWER('marc@amillion.com')) LIMIT 1
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE ("users"."confirmation_token" = 'DCo8QgqWQfnYWq20n5Uf') LIMIT 1
  AREL (31.0ms)  INSERT INTO "users" ("email", "encrypted_password", "password_salt", "reset_password_token", "remember_token", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "username", "f_name", "l_name", "created_at", "updated_at", "invitation_token", "invitation_sent_at", "plan_id", "current_state", "confirmation_token", "confirmed_at", "confirmation_sent_at") VALUES ('marc@amillion.com', '$2a$10$55hQTGZpUKbeT5n30/eyau96jf5zzd18t19jV/Y4g8Urou/El4vKy', '$2a$10$55hQTGZpUKbeT5n30/eyau', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'marcamillion', NULL, NULL, '2011-02-12 00:20:03.699983', '2011-02-12 00:20:03.699983', NULL, NULL, NULL, NULL, 'DCo8QgqWQfnYWq20n5Uf', NULL, '2011-02-12 00:20:03.699855')
Rendered devise/mailer/confirmation_instructions.html.erb (1.0ms)

Sent mail to marc@amillion.com (30009ms)
Date: Fri, 11 Feb 2011 19:20:03 -0500
From: no-reply@myapp.com
To: marc@amillion.com
Message-ID: <4d55d233bfe9f_bd4880443b3c837ee@MyMacBook-Pro.local.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome marc@amillion.com!</p>

<p>You can confirm your account through the link below:</p>

<p><a href="http://localhost:3000/users/confirmation?confirmation_token=DCo8QgqWQfnYWq20n5Uf">Confirm my account</a></p>
Completed   in 30349ms

Timeout::Error (execution expired):

1 Ответ

2 голосов
/ 12 февраля 2011

Я предполагаю, что у вас нет SMTP-сервера, работающего локально. Если вам действительно не нужно, чтобы почта доставлялась в процессе разработки, вы можете удалить этот материал, и он не должен выдавать ошибку:

config.action_mailer.default_url_options = { :host => 'localhost:3000' } #Make sure to set 'host' to domain name in production.  
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

Если вы хотите, чтобы почта доставлялась в dev, то Google настраивает SMTP-сервер. Или вы даже можете использовать что-то вроде gmail в качестве SMTP-сервера

...