簡體   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