Instant Rails データベースを作る
phpMyAdmin というDB管理ツールを使ってみる
- プロジェクトを作る
rails_apps>rails -d mysql addressBook
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create components
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/mocks/development
create test/mocks/test
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create public/.htaccess
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/breakpointer
create script/console
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.logC:\InstantRails\rails_apps>
- データベース設定確認
「config\database.yml」
development:
adapter: mysql
database: addressBook_development
username: root
password:
host: localhost
- データベース設定項目
設定項目 | 項目の意味 |
---|---|
adapter | 使用するデータベースの種類 |
database | 使用するデータベース名 |
username | データベース接続に使用するユーザー名 |
password | データベース接続に使用するパスワード |
host | データベースが動いているホスト名 |
- アプリケーションの枠組みを作る
addressBook>ruby script/generate scaffold address address
exists app/controllers/
exists app/helpers/
create app/views/address
exists app/views/layouts/
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/address.rb
create test/unit/address_test.rb
create test/fixtures/addresses.yml
create app/views/address/_form.rhtml
create app/views/address/list.rhtml
create app/views/address/show.rhtml
create app/views/address/new.rhtml
create app/views/address/edit.rhtml
create app/controllers/address_controller.rb
create test/functional/address_controller_test.rb
create app/helpers/address_helper.rb
create app/views/layouts/address.rhtml
create public/stylesheets/scaffold.css