为什么我无法从开发数据库访问我的url_helpers?

时间:2016-04-25 20:11:51

标签: ruby-on-rails

我的rails应用程序中有一个文件,其中包含以下路径:lib/reverification/template.rb

以下是此文件内容的摘要:

module Reverification
   class Template
      class << self
         delegate :url_helpers, to: 'Rails.application.routes'

         def first_reverification_notice(email)
           { to: email@gmail.com,
             from: fromemail@gmail.com,
             subject: reverify your email,
             body_html: "Here is some text to reverify, click this link to do so #{verify_link}"}
         end


         def verify_link
            "<a href=#{url_helpers.new_authentication_url(host: ENV['URL_HOST'])}>reverification link</a>"
         end
      end
   end
end

当我rails c进入我的开发数据库并尝试执行该方法时,first_reverification_notice我收到此错误:NameError: undefined local variable or method url_helpers' for main:Object

为什么我会收到此错误,如何避免错误?我尝试过执行

include Rails.application.routes.url_helpers但这不起作用。我可以尝试做些什么呢?感谢您的帮助。

0 个答案:

没有答案