• Develop a database object design for an online taxi booking system (OTBS);
• Revise database techniques with Rails and SQL
• Describe how to use the MVC “push-based architecture” in the Ruby on Rails development environment
To do:
1. Set up the MySQL tools on your computer as described in section 6 above.
The MySQL server 5.1 is downloaded from http://www.mysql.com and installed into my laptop as follows:
2. Rails will setup a new application directory for each of your Web application projects. Get InstantRails (Windows) or Locomotive (MacOS) running on your machine. Both packages install Ruby, Rails, a Web server or one called ‘Mongrel’ or another small Ruby Web server called ‘WEBrick’, and MySQL “inside a bubble” as I call it so that others parts of your system are not modified (Similarly ZOPE does with installing its own Web server and Python versions).
Ruby on Rails installer for Windows 1.8.7 package is downloaded from http://www.rubyonrails.org and installed.
Command “gems install rails --include-dependencies” is issued to install GEMS. Another command “gem update rails” is also required to grab the most recent updates from the official web.
3. Once Rails is running you at http://localhost:3000, you need to configure database access. Connection to the database is specified in the config/database.yml file.
“Rails Taxi” command is used to generate the data model for the Taxi project with the following hierarchy
C:\Ruby>rails Taxi
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
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_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create db/seeds.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
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
Change to the Taxi directory C:\Ruby\Taxi and issue the command “ruby script/server” to run WEBrick web server on the machine and to test if the environment is ready or not.
C:\Ruby\Taxi>ruby script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-04-15 10:03:32] INFO WEBrick 1.3.1
[2010-04-15 10:03:32] INFO ruby 1.8.7 (2010-01-10) [i386-mingw32]
[2010-04-15 10:03:32] INFO WEBrick::HTTPServer#start: pid=3444 port=3000
If the environment is setup successfully it would show the following.
The connection of database is required to be specified in the file which is located in C:\Ruby\Taxi\config\database.yml with the following content.
4. Generate the Passenger model by creating the MySQL database and ‘passengers’ table from the information above.
There is a tool for GUI interface to manage MySQL called MySQL-Front is downloaded and installed. Database “Taxi” is created with table “Passenger” inserted. The required field for the table is also inserted according as follows.
5. Further work on understanding MySQL under Rails by David Mertz:
a. See “Fast-track your Web apps with Ruby on Rails” at http://www-128.ibm.com/developerworks/linux/library/l-rubyrails/
b. The “Rolling with Ruby on Rails” series and “Cookbook recipes by Curt Hibbs and others beginning at http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
Both resources links has been reviewed. I would find the second link to be extremely useful and practical for this Workshop which is a hands on step-by-step guide to setup the RoR environment with the association to the database MySQL. It also mentioned the tools for managing MySQL in depth which is very useful for students like me who is not a DBA typing SQL query commands everyday.
Recommended time: 1-4 hours, but it may take several trial attempts so be patient with initial success.
Challenge Problems: There are enough already in this workshop.
Nice article! keep up the good work.
ReplyDeletetaxi booking app builder