rails轮换首页

rails替换首页
开始rails旅程~
新建一个rails应用后,使用rails server启动服务器后,默认在3000端口默认会显示public/index.html,要更换为自己想要的首页那么可以按照如下步骤进行:
1.生成自己的首页,例如:rails g controller home index,编辑app/views/home/index.html.erb
2.删除public/index.html,因为rails默认会优先使用public目录下的静态文件(如果保留public/index.html,就算执行了操作3,访问首页显示的也是public/index.html的内容)
3.编辑config/routes.rb文件,找到 #root :to这一行,将其改为root :to => home#index
即完成了对首页的替换~
You should put the root route at the top of the file, because it is the most popular route and should be matched first.