문제

I'm very new to ROR and very impressed so far, its extremely fast and structured well. 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?

As in (for a normal site) putting a index.html in the root.

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

To set homepage add following line to the end of the routes.rb file:

 root :to => "welcome#index"

and delete public/index.html.erb.

Please also note that welcome#index corresponds to index action in a WelcomeController

Rails 4

 root 'welcome#index'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top