首页 文章

为什么Localhost:3000指向默认页面?

提问于
浏览
0

我是Rails的新手 . 在rails运行的情况下,打开 localhost:3000 将我带到默认"welcome aboard"页面 . Rake routes命令发出一条消息,我不会在 config/routes.rb 中更改任何内容 .

我试图下载我的github存储库,但问题仍然存在 . 好吗,拜托?

@MarcinAdamczyk,@ RichPeck . 我应该说localhost以前做过 . 这就是我所拥有的:

1)Pinteresting :: Application.routes.draw做资源:引脚

devise_for :users
devise_for :installs
root "pages#home"
get "about" => "pages#about"

2)class ApplicationController <ActionController :: Base#通过引发异常来防止CSRF攻击 . #对于API,您可能希望使用:null_session . protect_from_forgery with :: exception end

def home end

3)类PagesController <ApplicationController def home end

def about

结束

2 回答

  • 0

    如果您使用Rails <4,则需要从 public 文件夹中删除 index.html 并在 config/routes.rb 中设置 root to: 'controller#method'

    如果它的Rails 4那么只设置根路由就足够了 .

  • 3

    Routes

    您需要更改路线以获得以下内容:

    #config/routes.rb
    root "application#index"
    

    然后,您可以创建和相应的控制器操作:

    #app/controllers/application_controller.rb
    class ApplicationController < ActionController::Base
       def index
       end
    end
    
    #app/views/application/index.html.erb
    Test
    

    根据您发布的内容判断,这应该可以解决您的问题 .

相关问题