Railsã§BBSãä½ã£ã¦ã¿ã
C:\src\ruby>rails testbbs create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create config/initializers 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/initializers/inflections.rb create config/initializers/mime_types.rb 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/console create script/destroy create script/generate create script/performance/benchmarker create script/performance/profiler create script/performance/request 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/422.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.log C:\src\ruby>cd testbbs
config/database.yaml ã¯sqlite3ãããã©ã«ãã«ãªã£ã¦ãããã®ã¾ã¾ã§ãã
# SQLite version 3.x # gem install sqlite3-ruby (not necessary on OS X Leopard) development: adapter: sqlite3 database: db/development.sqlite3 timeout: 5000 # Warning: The database defined as 'test' will be erased and # re-generated from your development database when you run 'rake'. # Do not set this db to the same as development or production. test: adapter: sqlite3 database: db/test.sqlite3 timeout: 5000 production: adapter: sqlite3 database: db/production.sqlite3 timeout: 5000
ç¶ãã¦scaffoldã§model/view/controllerãå ¨é¨ä½ããmessage(æ稿è ã¨æ¬æ)ã
C:\src\ruby\testbbs>ruby script/generate scaffold message name:string body:text exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/messages exists app/views/layouts/ exists test/functional/ exists test/unit/ create app/views/messages/index.html.erb create app/views/messages/show.html.erb create app/views/messages/new.html.erb create app/views/messages/edit.html.erb create app/views/layouts/messages.html.erb create public/stylesheets/scaffold.css dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/message.rb create test/unit/message_test.rb create test/fixtures/messages.yml create db/migrate create db/migrate/001_create_messages.rb create app/controllers/messages_controller.rb create test/functional/messages_controller_test.rb create app/helpers/messages_helper.rb route map.resources :messages
migrateããï¼SQLiteã®DBã db/migrate/001_create_messages.rb ã«å¾ã£ã¦ä½æããï¼
rake db:migrate VERSION=001
ã¡ãªã¿ã«ä¸æ¦DBãåæåãããæã¯000ã
ã§ã¯WEBrickã§åããã¦ã¿ã
ruby script/server
http://localhost:3000/messages ããè¦ãã