1

我正在使用设计,我认为一切正常,直到我试图重置密码。我收到以下错误。设计找不到名为布局/电子邮件的模板。为什么它甚至想要那个?我的印象是,在表单发布后,设计会重定向到用户登录页面。

我怀疑设计无法找到“reset_password_instructions.html.haml”文件,因为它显然能够生成重置令牌,但实际上没有发送任何电子邮件。根据下面的错误消息,这听起来像是正确的诊断吗?

我该怎么做才能解决这个问题?我猜我必须通过覆盖控制器来修改设计,但我不确定。有什么建议么?

Started POST "/users/password" for 127.0.0.1 at 2012-08-06 05:52:42 -0500
    Processing by Devise::PasswordsController#create as HTML
      Parameters: {"utf8"=>"✓", "authenticity_token"=>"kGvuZiu+iu1HAx9xf4RsISj2SM410uLRoR6RbiJcBQw=", "user"=>{"email"=>"test1@example.com"}, "commit"=>"Send me reset password instructions"}
      User Load (6.0ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'test1@example.com' LIMIT 1
      User Load (1.3ms)  SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = '5QZVFAsq2ev22gpQfe9i' LIMIT 1
       (0.1ms)  BEGIN
       (3.0ms)  UPDATE "users" SET "reset_password_token" = '5QZVFAsq2ev22gpQfe9i', "reset_password_sent_at" = '2012-08-06 10:52:42.591763', "updated_at" = '2012-08-06 10:52:42.593474' WHERE "users"."id" = 2
       (0.5ms)  COMMIT
    DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:haml] instead. (called from call at /Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/sass-3.1.19/lib/sass/plugin/rack.rb:54)
    DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:haml] instead. (called from call at /Users/bendowney/.rvm/gems/ruby-1.9.3-p194@global/gems/sass-3.1.19/lib/sass/plugin/rack.rb:54)
    Completed 500 Internal Server Error in 113ms

    ActionView::MissingTemplate (Missing template layouts/email with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
      * "/Users/bendowney/Sites/RobotimusApp/app/views"
      * "/Users/bendowney/.rvm/gems/ruby-1.9.3-p194@RobotimusApp/gems/devise-2.1.2/app/views"
    ):
      actionpack (3.2.5) lib/action_view/path_set.rb:58:in `find'
      actionpack (3.2.5) lib/action_view/lookup_context.rb:109:in `find'
      actionpack (3.2.5) lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
      actionpack (3.2.5) lib/action_view/renderer/template_renderer.rb:79:in `resolve_layout'
      actionpack (3.2.5) lib/action_view/renderer/template_renderer.rb:86:in `resolve_layout'
      actionpack (3.2.5) lib/action_view/renderer/template_renderer.rb:69:in `block in find_layout'
      actionpack (3.2.5) lib/action_view/lookup_context.rb:228:in `with_layout_format'
#...etc
4

1 回答 1

2

在重定向用户之前,Devise 会发送一封带有重置令牌的电子邮件。发送电子邮件还需要模板和布局。在您的情况下,此步骤失败,因为您可能在代码中的某处指定layout 'email'了 ActionMailer 类,但实际上并未创建此布局模板。

尝试添加一个app/views/layouts/email.html.haml至少包含以下内容的文件:

= yield

(或<%= yield %>在 .html.erb 模板中)。

于 2012-08-06T11:35:58.020 回答