繁体   English   中英

Ruby on Rails index.html.erb无法加载

[英]Ruby on Rails index.html.erb not loading

刚从Rails开始,我试图让我的index.html.erb页面显示在我进入Rails-backend子域时。

我一直在按照本指南中的说明进行操作,但遇到了一些麻烦。 搜索谷歌和SO的答案没有产生结果,所以我在这里。

我运行$ rails generate controller home index来生成index.html.erb ,并删除了public/index.html 然后,我转到/ config目录中的routes.rb文件,并添加以下行:

root :to => 'home#index'

我也删除了这一行:

get "home/index"

我在app/views/home/目录中的index.html.erb看起来像这样:

<h1>Hello Rails, my best friend!</h1>
<p>Find me in app/views/home/index.html.erb</p>
<br />
<p>Also word to your mother</p>

我在终端上运行了rake routes ,并得到以下输出:

(在var / www / testapp中)root / home#index

当我尝试转到自己的子域时,会显示以下页面:

错误

然后,我尝试取消注释route.rb中的get "home/index"行,但显示了相同的结果。 这是我的home_controller.rb文件,我没有碰过它,但是a)指南没有要求我输入,b)与我见过的其他控制器相比看起来很正常:

class HomeController < ApplicationController
  def index
  end
end

我敢肯定这是一个简单的问题,但我找不到类似情况的任何问题。 感谢您的帮助!

您的代码看起来都很正确。 我建议使用前述的Passenger,而改用Thin Server。 它同时处理httphttps

就这么简单:

  • Gemfile添加到您的GemfileGemfile gem 'thin'
  • 安装gem: bundle
  • 启动服务器: bundle exec thin start --ssl

这样,您将获得Mongrel解析器和SSL的好处,而无需任何自定义Apache配置。

暂无
暂无

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

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