-1

基本的な Ruby on Rails サーバーのセットアップがあります。

routes.rb には次のものがあります。

ActionController::Routing::Routes.draw do |map|

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'

  root :to => "home#index"
end

私の controller/application_controller.rb には、次のものがあります。

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
end

最後に、いくつかの基本的な HTML を含む /app/views/posts/index.html.erb を作成しました。ページでその HTML ファイルを参照するにはどうすればよいですか。

4

1 に答える 1

0

これを試して:

ActionController::Routing::Routes.draw do
  root :to => "main_controller#index"
  match 'home' => 'main_controller#index'
end

ここで、main_controller は、メイン ページとして使用するコントローラーの名前です。

matchを入力するとlocalhost:3000/home、指定したコントローラーとの照合が行われます。

rake routesプロジェクト内のルートのリストを提供するコマンドを実行することで、有効なルートを確認できます。

http://guides.rubyonrails.org/routing.html -5 Inspecting and Testing Routes を確認してください。

于 2012-09-07T03:25:23.623 に答える