プログラミングはおっくせんまん
プログラミングに関する個人的なメモを綴るだけのブログです。 よろしぷ。あ、間違えた、よろしく。
GrandPrixLegedsリザルト管理システム〜サーバ(プロジェクト作成)〜
【環境】
WindowsXP HomeEdition
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Rails 2.0.2
SQLite version 3.5.4

【コマンドプロンプトにて構築】
>rails GPLServer
GPLServer/config/database.ymlにてdatabaseをgplserver_development.sqlite3に変更
>cd gplserver
>ruby script/generate scaffold event eventName:string startDate:date endDate:date
>rake db:migrate
>ruby script/generate scaffold round event_id:integer roundNo:integer ・・・(長いので略)
>rake db:migrate
>ruby script/generate scaffold result round_id:integer driverName:string ・・(さらに超長いので略)
>rake db:migrate


テーブルができてるか確認
>sqlite3 db/gplserver_development.sqlite3
sqlite>.schema


【テーブルのリレーション設定】
event:round = 1:N
round:result = 1:N
となるようにする。

GPLServer\app\models\event.rb
class Event < ActiveRecord::Base
 has_many :rounds
end

GPLServer\app\models\round.rb
class Round < ActiveRecord::Base
 belongs_to :event
 has_many :results

end

GPLServer\app\models\result.rb
class Result < ActiveRecord::Base
 belongs_to :round
end

サーバ起動
>ruby script/server

以下、正常に表示されることを確認
http://localhost:3000/events
http://localhost:3000/rounds
http://localhost:3000/results





管理者にだけ表示を許可する





TRACK BACK
TB*URL





Copyright © プログラミングはおっくせんまん. all rights reserved.
無料ホームページ アフィリエイト レンタルサーバー FC2ブログ 一戸建て