● 基本
MacOS 10.6.6 に含まれる Rails:
$ ruby -v → Ruby 1.8.7 (universal-darwin10.0)
$ rails -v → Rails 2.3.5
$ gem -v → Gems 1.3.5
$ sqlite3 -version → SQLite3 3.6.12
$ cd /Users/xxxxxx ( /home/xxxxxx に相当する場所)
$ rails photos ( "photos" というアプリケーションを作成。このコマンドで "photos"というディレクトリが作成され、そこに最低限必要なアプリケーションの要素が作成される)
$ cd photos
$ ruby script/server ("photos" ディレクトリに入り、ruby コマンドで Web サーバーを立ち上げる)
Macname:~ xxxxxx$ ls
Applications Downloads Music Sites
Desktop Library Pictures eclipse-workspace
Documents Movies Public photos
Macname:~ xxxxxx$ cd photos
Macname:photos xxxxxx$ ruby script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
$ ruby -v → Ruby 1.8.7 (universal-darwin10.0)
$ rails -v → Rails 2.3.5
$ gem -v → Gems 1.3.5
$ sqlite3 -version → SQLite3 3.6.12
$ cd /Users/xxxxxx ( /home/xxxxxx に相当する場所)
$ rails photos ( "photos" というアプリケーションを作成。このコマンドで "photos"というディレクトリが作成され、そこに最低限必要なアプリケーションの要素が作成される)
$ cd photos
$ ruby script/server ("photos" ディレクトリに入り、ruby コマンドで Web サーバーを立ち上げる)
Macname:~ xxxxxx$ ls
Applications Downloads Music Sites
Desktop Library Pictures eclipse-workspace
Documents Movies Public photos
Macname:~ xxxxxx$ cd photos
Macname:photos xxxxxx$ ruby script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
● ブラウザで起動を確認
アドレス: 127.0.0.1:3000
● Scaffold (フィールドの定義)
$ cd photos (上記と同じ場所)
$ ruby script/generate scaffold photo key:integer alb_tt:text place:text content:text year1:integer year2:string month:integer day:integer filename:text image:text cd_no:string dvd_no:string region:string remark:text people:text
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/photos
exists app/views/layouts/
exists test/functional/
exists test/unit/
create test/unit/helpers/
exists public/stylesheets/
create app/views/photos/index.html.erb
create app/views/photos/show.html.erb
create app/views/photos/new.html.erb
create app/views/photos/edit.html.erb
create app/views/layouts/photos.html.erb
create public/stylesheets/scaffold.css
create app/controllers/photos_controller.rb
create test/functional/photos_controller_test.rb
create app/helpers/photos_helper.rb
create test/unit/helpers/photos_helper_test.rb
route map.resources :photos
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/photo.rb
create test/unit/photo_test.rb
create test/fixtures/photos.yml
create db/migrate
create db/migrate/20110324120355_create_photos.rb
Macname:photos xxxxxx$
● ブラウザで表示してみる
アドレス: 127.0.0.1:3000
● Scaffold (フィールドの定義)
$ cd photos (上記と同じ場所)
$ ruby script/generate scaffold photo key:integer alb_tt:text place:text content:text year1:integer year2:string month:integer day:integer filename:text image:text cd_no:string dvd_no:string region:string remark:text people:text
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/photos
exists app/views/layouts/
exists test/functional/
exists test/unit/
create test/unit/helpers/
exists public/stylesheets/
create app/views/photos/index.html.erb
create app/views/photos/show.html.erb
create app/views/photos/new.html.erb
create app/views/photos/edit.html.erb
create app/views/layouts/photos.html.erb
create public/stylesheets/scaffold.css
create app/controllers/photos_controller.rb
create test/functional/photos_controller_test.rb
create app/helpers/photos_helper.rb
create test/unit/helpers/photos_helper_test.rb
route map.resources :photos
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/photo.rb
create test/unit/photo_test.rb
create test/fixtures/photos.yml
create db/migrate
create db/migrate/20110324120355_create_photos.rb
Macname:photos xxxxxx$
● ブラウザで表示してみる
● データベース作成のステップ
/Users/xxxxxx/photos/db/migrate/ に "20110324120355_create_photos.rb" が作成され、これを元にデータベースのテーブルが作成される
0 件のコメント:
コメントを投稿