Heroku / devise - 丢失主机链接到!请提供:host参数或set default_url_options [:host] [英] Heroku/devise - Missing host to link to! Please provide :host parameter or set default_url_options[:host]

查看:125
本文介绍了Heroku / devise - 丢失主机链接到!请提供:host参数或set default_url_options [:host]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把我的应用推向英雄。我还在开发
我使用devise与可确认的模块。



当我尝试添加一个用户与英雄控制台我得到这个错误:

 缺少主机链接到!请提供:host参数或设置default_url_options [:host] 

在测试和开发环境中,我有以下行:



environments / development.rb和environments / test.rb



  config.action_mailer.default_url_options = {:host => 'localhost:3000'} 

我没有在生产环境中设置一些东西。 p>

我试图用

  config.action_mailer.default_url_options = {:host => 'mywebsitename.com'} 
config.action_mailer.default_url_options = {:host => 'heroku.mywebsitename.com'}

但它不起作用..



我在网上看到它可能与ActionMailer相关,但我不知道我要配置什么。
非常感谢你的想法!



EDITED:





为了不使我的应用程序崩溃,当我推动heroku我把它放在我的env / test.rb和我的env / dev.rb(不是在env.rb我认为是因为这是一个rails 3应用程序)

  config.action_mailer.default_url_options = {:host => 'yourapp.heroku.com'} 

但是当我尝试在heroku控制台中创建一个用户时:

  User.create(:username =>test,:email =>test@test.com :password =>test1234,:password_confirmation =>test1234,:confirmation_at =>2010-11-03 14:11:15.520128)

这里是我收到的错误:

  ActionView :: Template: :错误:缺少主机链接到!请提供:host参数或set default_url_options [:host] 
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/ route_set.rb:473:在`url_for'
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/url_for。 rb:132:在`url_for'
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_view/helpers/url_helper.rb中: 99:在`url_for'
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/route_set.rb:195:在'user_confirmation_url'



EDITED(2)



当我在控制台上输入heroku日志时,我得到这个==> production.log< ==所以我认为当一个部署在heroku上它已经在生产中。



我这样配置env / prod.rb:

  config.action_mailer.default_url_options = {:host => 'yourapp.heroku.com'} 

现在我有这个错误,当我尝试创建一个用户:

  Errno :: EAFNOSUPPORT:协议不支持的地址族 - 套接字(2)
/ usr / ruby​​1 .8.7 / lib / ruby​​ / 1.8 / net / smtp.rb:551:在'initialize'
/usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in`open'
/usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in`do_start'
/usr/ruby1.8.7/lib/ruby/1.8/timeout.rb: 62:在超时


解决方案

您需要添加到你的 environment.rb

  config.action_mailer.default_url_options = {: host => 'localhost'} 

确保更改主机到你的生产网址,并保持它的localhost进行开发。这是邮件,它需要一个默认的电子邮件发出通知,如确认等...






你应该检查英雄服务器上的日志 heroku日志从控制台运行它,它会告诉你确切的错误。



当你推到heroku,你需要配置 environment.rb 文件与英雄子域名:

  config.action_mailer.default_url_options = {:host => 'yourapp.heroku.com'} 






根据版本,应该在 production.rb 中,而不是 environment.rb


I am trying to push my app on heroku. I am still in dev. I use devise with the confirmable module.

When I try to add a user with the heroku console I got this error:

Missing host to link to! Please provide :host parameter or set default_url_options[:host]

in test and dev environment i have the following line:

environments/development.rb and environments/test.rb

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

I don't have set up something in the production environment.

I've tried to push with

config.action_mailer.default_url_options = { :host => 'mywebsitename.com' }
config.action_mailer.default_url_options = { :host => 'heroku.mywebsitename.com' }

but it doesn't work too..

I see on the web that it could be related to ActionMailer but I don't know what I have to configure. Many thanks for your idea!

EDITED:

Hi,

In order to not make my app crashes when I push on heroku I put this in my env/test.rb and my env/dev.rb (not in env.rb I think it is because it's a rails 3 app)

config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }

But when I tried to create a user in the heroku console:

User.create(:username => "test", :email => "test@test.com", :password => "test1234", :password_confirmation => "test1234", :confirmed_at => "2010-11-03 14:11:15.520128")

here are errors I got:

ActionView::Template::Error: Missing host to link to! Please provide :host parameter or set default_url_options[:host]
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/route_set.rb:473:in `url_for'
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/url_for.rb:132:in `url_for'
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_view/helpers/url_helper.rb:99:in `url_for'
/home/slugs/.../mnt/.bundle/gems/ruby/1.8/gems/actionpack-3.0.0/lib/action_dispatch/routing/route_set.rb:195:in `user_confirmation_url'

EDITED (2)

When I type heroku logs on console I got this ==> production.log <== So I think when one deploys on heroku it's already in production.

I configure the env/prod.rb like this:

config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }

and now I have this as error when I try to create a User:

Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
/usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in `initialize'
/usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in `open'
/usr/ruby1.8.7/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/usr/ruby1.8.7/lib/ruby/1.8/timeout.rb:62:in `timeout'

解决方案

You need to add this to your environment.rb

  config.action_mailer.default_url_options = { :host => 'localhost' }

Make sure you change host to your production url and keep it localhost for development. This is for the mailer, it needs a default email to send out notices such as confirmations etc...


You should check the logs on the heroku server heroku logs run that from the console and it will tell you the exact error.

When you push to heroku you need to configure the environment.rb file with the heroku subdomain:

config.action_mailer.default_url_options = { :host => 'yourapp.heroku.com' }


Depending upon version, this should go in production.rb, not environment.rb.

这篇关于Heroku / devise - 丢失主机链接到!请提供:host参数或set default_url_options [:host]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆