您好我们将应用程序复制到新域并在日志中收到以下错误。任何人都可以指出我们正确的方向,因为我们不是Ruby on Rails的专家吗?
F, [2018-04-17T07:01:04.366958 #32309] FATAL -- : [e1fdedc8-ccf2-4537-a2ca-2760fd71eb68]
F, [2018-04-17T07:01:04.367095 #32309] FATAL -- : [e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
F, [2018-04-17T07:01:04.367316 #32309] FATAL -- : [e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 87: </tr>
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 88: <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> <td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 89: <p>
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 90: <a href="<%= lead_url(@lead, host: ENV['root_url'] ) %>"> <%= @lead.address %></p>
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 91: </td>
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 92: </tr>
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] 93: <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"><td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
F, [2018-04-17T07:01:04.367370 #32309] FATAL -- : [e1fdedc8-ccf2-4537-a2ca-2760fd71eb68]
F, [2018-04-17T07:01:04.367412 #32309] FATAL -- : [e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] app/views/offer_mailer/lead_received_email.html.erb:90:in `_app_views_offer_mailer_lead_received_email_html_erb__2123924889929648841_69874930248760'
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] app/mailers/offer_mailer.rb:6:in `lead_received_email'
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] app/controllers/wizards_controller.rb:79:in `email_notify_agent'
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] app/controllers/wizards_controller.rb:54:in `notify_agent'
[e1fdedc8-ccf2-4537-a2ca-2760fd71eb68] app/controllers/wizards_controller.rb:31:in `validate_step'
答案 0 :(得分:0)
尝试添加以下行的config/environment.rb
文件
Rails.application.routes.default_url_options = { :host => "https://example.herokuapp.com" }
#=> host you can change your domain
您可以在development.rb
,production.rb
和test.rb
<强> production.rb 强>
config.action_mailer.default_url_options = { :host => "https://example.herokuapp.com" }
确保在进行更改后重新启动服务器
<强>更新强>
现在我认为ENV['root_url']
引发的问题,你可以改变这个,如下所示
<%= lead_url(@lead, host: 'https://your-domain.com' ) %>
用于测试目的,看看发生了什么,如果它正在工作,那么你可以以正确的方式设置环境变量
对于环境变量,您可以使用Figaro
gem,将Figaro添加到Gemfile
并捆绑安装:
gem "figaro"
费加罗安装很简单:
bundle exec figaro install
#=> create config/application.yml
安装后转到config/application.yml
并添加这样的网址
root_url: "https://you-domain.com"
然后现在
<%= ENV['root_url'] %>
#=> https://you-domain.com