開発用&テスト用環境の構築

(5385d) 更新


このページの内容は非常に古いです(Rails 1.x.x)。最新の Rails では洗練された国際化の機構が標準で入っているため、下記は読むだけ無駄な内容になっています。

ソフトウェア/rails/言語ネゴシエーション

negotiation という名前のアプリケーションの作成

テスト用に negotiation という名前のアプリケーションを作成。

LANG:console
$ rails negotiation
$ cd negotiation

開発用サーバーの起動と環境の確認

LANG:console
$ script/server &
$ wget -qO- http://localhost:3000/ | html2text
 ...
 
 ****** Welcome aboard ******
 ***** You’re riding Ruby on Rails! *****
 **** About_your_application’s_environment ****
 ...
 
$ $ ls db/*
 ls: cannot access db/*: そのようなファイルやディレクトリはありません
$ wget -qO- http://localhost:3000/rails/info/properties | html2text
 Ruby version            1.8.7 (i486-linux)
 RubyGems version        1.3.2
 Rails version           2.2.2
 Active Record version   2.2.2
 Action Pack version     2.2.2
 Active Resource version 2.2.2
 Action Mailer version   2.2.2
 Active Support version  2.2.2
 Edge Rails revision     unknown
 Application root        (rails)/negotiation
 Environment             development
 Database adapter        sqlite3
 Database schema version 0
$ ls db/*
 db/development.sqlite3

このとき自動的に sqlite3 のデータベースが作成される。

test コントローラとビューの作成

LANG:console
$ script/generate controller Test
     exists  app/controllers/
     exists  app/helpers/
     create  app/views/test
     exists  test/functional/
     create  app/controllers/test_controller.rb
     create  test/functional/test_controller_test.rb
     create  app/helpers/test_helper.rb
$ echo "Test" > app/views/test/index.html.erb
$ (restart script/server)
$ wget -qO- http://localhost:3000/test
 Test

#### 次へ?
#### 上へ


Counter: 4390 (from 2010/06/03), today: 1, yesterday: 0