我目前還沒有指數的看法(app/views/mycontroller/index.html.erb
),但想,如果用戶只是類型指定一個默認視圖:localhost:3000/mycontroller
添加默認視圖爲Rails控制器
很新的回報率。我現在config/routes.rb
:
MyTestApp::Application.routes.draw do
get "team/thatguy"
get "home/about"
root :to => "home#about"
end
在我的控制,我一直與重定向玩弄,但所需的解決方案是,只顯示小URI localhost:3000/mycontroller
。
應用程序/控制器/ home_controller.rb:
class HomeController < ApplicationController
def index
render "home/about"
end
def about
@title = "My Title"
end
end
哪個模板你想在用戶訪問'/ mycontroller'渲染? – tkymtk
我只有一個模板。這是一個非常基本的,完全靜態的網站,只有一個聯繫表格。 – tarabyte