我已经解决了标题中描述的错误的众多解决方案。
ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
但是,该项目还修改了 url_for 函数以使用子域,如以下 railscast 所示:
http://railscasts.com/episodes/221-subdomains-in-rails-3
所以,这个错误的传统答案,例如在我的环境设置中设置变量似乎不是解决方案。
以下是一些其他提示:
- 这是一个全新的设置,我刚刚克隆了一个项目并安装了 ruby、rails、gems 等
- 我已经尝试过“rvm implode”并重新开始很多次
- 团队的其他成员通常在 Mac 上进行本地开发,而我在 Ubuntu 机器上进行远程开发。
- 我以 root 身份工作(这有关系吗?)
在 1889 毫秒内完成 500 内部服务器错误
ActionView::Template::Error (缺少要链接的主机!请提供 :host 参数,设置 default_url_options[:host],或设置 :only_path 为 true): 1: %header.menu{:role => "banner" } 2: .col980 3: %h1 4: %a.logo{:href => root_url({:subdomain => false})} 5: -if current_user.premium? 6: %img{:alt => "Contently", :src => "/images/logo_beta_premium.png"}/ 7: -else app/helpers/url_helper.rb:16:in url_for'
app/views/shared/_logged_in_writer_nav.html.haml:4:in
_app_views_shared__logged_in_writer_nav_html_haml__656388632_107925510' app/views/layouts/ application.html.haml:35:in block in _app_views_layouts_application_html_haml__193634629_107212530'
app/helpers/application_helper.rb:15:in
html5_haml_tag' app/views/layouts/application.html.haml:2:in _app_views_layouts_application_html_haml__193634629_107212530'
app/controllers/application_controller.rb:18:in
error_generic'