Ruby on Rails
レス数が950を超えています。1000を超えると書き込みができなくなります。
0993デフォルトの名無しさん
2008/04/30(水) 14:34:44(1)DOSコマンドプロンプトで新規プロジェクトを作成(プロジェクト名hello)
C:\ruby>rails hello
(2)ウェブサーバを起動(デフォルト3000番ポート)
C:\ruby>cd hello
C:\ruby\hello>ruby script\server
(3)DOSコマンドプロンプトをもう一枚開いてMVCのC(コントローラ)を作成
C:\ruby\hello>ruby script\generate controller Top
C:\ruby\hello\app\controllers\top_contorller.rbに下記のようにindexメソッドを追加する。
class TopController < ApplicationController
def index #add
@message = "Hello world" #add
end #add
end
(4)MVCのV(ビュー)を作成
C:\ruby\hello\app\views\top\index.rhtmlに以下を記述して保存。
<%= @message %>
(5)マッピング C:\ruby\hello\config\routes.rbに一行追記
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.connect '',:controller=>"top", :action=>"index" #add
end
ブラウザでhttp://localhost:3000;にアクセスしても、『hello world』は表示されずです。http://localhost:3000/top/index;だと期待どおりに、『hello world』が表示されるので、
(5)のマッピングがうまくいってないのでしょうか? 何が悪いのか教えてください。
レス数が950を超えています。1000を超えると書き込みができなくなります。