简体   繁体   English

Ruby on Rails应用中的致命错误

[英]Fatal Error in Ruby on Rails App

Hi we had an app copied over to a new domain and are getting the following errors in the log. 嗨,我们有一个应用程序已复制到新域,并在日志中收到以下错误。 Can anyone point us in the right direction since we are no experts in Ruby on Rails? 既然我们不是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'

Try to the config/environment.rb file adding below line 尝试将config/environment.rb文件添加到以下行

Rails.application.routes.default_url_options = { :host => "https://example.herokuapp.com" } 
#=> host you can change your domain

you can use this separately in development.rb , production.rb and test.rb 您可以在development.rbproduction.rbtest.rb分别使用它

production.rb production.rb

config.action_mailer.default_url_options = { :host => "https://example.herokuapp.com" }

make sure restart the server after making changes 确保在进行更改后重新启动服务器

Update 更新

Now I think the issue raising for ENV['root_url'] , can you change this like below 现在我认为ENV['root_url']引发的问题,您可以像下面这样更改吗

<%= lead_url(@lead, host: 'https://your-domain.com' ) %> 

for test purpose and see what's happening, if it's working then you can set up the environment variable in the right way 出于测试目的,查看发生了什么,如果工作正常,则可以以正确的方式设置环境变量

For environment variable you can use Figaro gem, add Figaro to your Gemfile and bundle install: 对于环境变量,您可以使用Figaro gem,将Figaro添加到Gemfile并捆绑安装:

gem "figaro"

Figaro installation is easy: Figaro的安装很简单:

bundle exec figaro install
#=> create  config/application.yml

after installing this go to config/application.yml and add URL like this 安装后,转到config/application.yml并添加如下网址

root_url: "https://you-domain.com"

then now 那么现在

<%= ENV['root_url'] %>
#=> https://you-domain.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM