为什么默认页面正在调用,即使公共文件夹中的index.html.erb文件丢失了?

时间:2016-04-19 17:59:15

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 model-view-controller

我正在开发一个简单的ruby on rails app。服务器已经成功启动。然后当我们转到默认的web url localhost:3000 /默认路由被调用显示主页有关说明。但我们不想要这个所以需要删除主项目目录下的公共文件夹中的index.html.erb文件。真正的问题是文件丢失,仍然是默认页面正在加载。

这里真正发生了什么,index.html.erb文件位于何处。[不要标记它重复,因为这里问题不同]。如何调用另一条路线来显示一些mypage.html

服务器日志

Started GET "/" for ::1 at 2016-04-19 23:29:26 +0530
Processing by Rails::WelcomeController#index as HTML
  Rendered C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/templates/rails/welcome/index.html.erb (0.0ms)
Completed 200 OK in 36ms (Views: 35.1ms | ActiveRecord: 0.0ms)

公用文件夹中的文件:

400.html
422.html
500.html
favicon.ico
robots.txt

3 个答案:

答案 0 :(得分:0)

root添加到您的routes.rb

root 'MyController#my_action'

答案 1 :(得分:0)

您想为应用程序设置主目录。只需选择另一条路线,例如下面的例子。

root 'static_pages#home'

答案 2 :(得分:0)

找到此解决方案Link here Coffee脚本1.9.0与Windows不兼容。在我的Windows 7计算机上,使用1.8.0版解决了这个问题。

添加到Gemfile

gem 'coffee-script-source', '1.8.0'

然后,运行

bundle update coffee-script-source

并重新启动服务器(如果需要)