■テーブル定義 テーブル名:tbl_vms VM名:vm_name:string 備考:remarks:text 所有者ID:owner_id:integer ■scaffold実施 [root@rails01 ~]# cd rails_projects/sample/ [root@rails01 sample]# rails g scaffold tbl_vms vm_name:string remarks:text owner_id:integer Plural version of the model detected, using singularized version. Override with --force-plural. invoke active_record create db/migrate/20110919145646_create_tbl_vms.rb create app/models/tbl_vm.rb invoke test_unit create test/unit/tbl_vm_test.rb create test/fixtures/tbl_vms.yml route resources :tbl_vms invoke scaffold_controller create app/controllers/tbl_vms_controller.rb invoke erb create app/views/tbl_vms create app/views/tbl_vms/index.html.erb create app/views/tbl_vms/edit.html.erb create app/views/tbl_vms/show.html.erb create app/views/tbl_vms/new.html.erb create app/views/tbl_vms/_form.html.erb invoke test_unit create test/functional/tbl_vms_controller_test.rb invoke helper create app/helpers/tbl_vms_helper.rb invoke test_unit create test/unit/helpers/tbl_vms_helper_test.rb invoke assets invoke coffee create app/assets/javascripts/tbl_vms.js.coffee invoke scss create app/assets/stylesheets/tbl_vms.css.scss invoke scss create app/assets/stylesheets/scaffolds.css.scss [root@rails01 sample]# ■テーブル作成 [root@rails01 sample]# rake db:migrate (in /root/rails_projects/sample) == CreateTblVms: migrating =================================================== -- create_table(:tbl_vms) -> 0.0400s == CreateTblVms: migrated (0.0405s) ========================================== [root@rails01 sample]# ⇒mysql上で確認 mysql> show tables; +------------------------------+ | Tables_in_sample_development | +------------------------------+ | schema_migrations | | tbl_vms | +------------------------------+ 2 rows in set (0.00 sec) mysql> desc tbl_vms; +------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | vm_name | varchar(255) | YES | | NULL | | | remarks | text | YES | | NULL | | | owner_id | int(11) | YES | | NULL | | | created_at | datetime | YES | | NULL | | | updated_at | datetime | YES | | NULL | | +------------+--------------+------+-----+---------+----------------+ 6 rows in set (0.00 sec) ■ブラウザで確認 http://192.168.1.14:3000/tbl_vms/
2011年9月20日火曜日
scaffoldでサンプル作成
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿