简体   繁体   English

Ruby on Rails URL主页

[英]Ruby on Rails URL Homepage

I'm very new to ROR and very impressed so far, its extremely fast and structured well. 我对ROR还是很陌生,到目前为止印象深刻,它非常快速且结构良好。 I've been taught to use the command. 我被教导要使用命令。

rails generate controller Welcome index

I understand it so far as.. create me a non-db-driven page in a sub-directory.. so the above would be: 就我而言,我理解它。.在子目录中创建一个非数据库驱动的页面..因此上述内容将是:

localhost:3000/welcome/index

but what if I want my domain www.something.com (localhost:3000) to be the homepage? 但是,如果我想将我的域名www.something.com(localhost:3000)用作主页怎么办?

As in (for a normal site) putting a index.html in the root. 就像在(对于普通站点)一样,在根目录中放置index.html。

is this possible, is there a reason I cant find the answer anywhere? 这可能吗,是否有原因我无法在任何地方找到答案?

Thank you in advance. 先感谢您。

You can make the index action of the welcome controller the homepage: 您可以将欢迎控制器的索引操作设为主页:

# config/routes.rb
root to: 'welcome#index'

See the documentation for more information. 请参阅文档以获取更多信息。

Rails 3.x Rails 3.x

To set homepage add following line to the end of the routes.rb file: 要设置主页,请将以下行添加到routes.rb文件的末尾:

 root :to => "welcome#index"

and delete public/index.html.erb. 并删除public / index.html.erb。

Please also note that welcome#index corresponds to index action in a WelcomeController 另请注意,welcome#index对应于WelcomeController中的索引操作

Rails 4 滑轨4

 root 'welcome#index'

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

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