4/07/2009

Workshop 3-part 1

To DO

1. Set up the MySQL tools on your computer as described in section 6 above.
a.) Download MYSQL GUI ToolsI. Download mysql-gui-tools-5.0-r17-win32.msi from http://dev.mysql.com/downloads/gui-tools/5.0.htmlII.

b.) Install MYSQL GUI Tools by following the prompted instruction of MYSQL.

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).

a.) Download InstantRails-2.0-win.zip from http://rubyforge.org/projects/instantrails/
b.) Extract all zip files from InstantRails-2.0-win.zip to c:\
c.) Check that my instantrails 2.0 covers




  • ruby verison is 1.86 patch level 111
  • rails verison is 2.0.2
  • mysql version is 5.0.27
  • mongrel version is 1.1.5
  • PHP 4.3.10
d.) Create a new application by issuing the command -"rails -d mysql C:\rails_apps\taxiapp"

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.

a.) Start the web application by issuing the command -"C:\rails_apps\taxiapp>mongrel_rails start -e development" and test by accessing the web page at http://localhost:3000/ by internet browser.

b.) First, you should create three database manually for test, development and production environments. Second, make sure the root's password does correctly input in config/database.yml file and make sure the info of database is mapping with current existed database in mysql.

4. Generate the Passenger model by creating the MySQL database and ‘passengers’ table from the information above.

a.) Create a model named passenger in the taxiapp directory by issuing the command "ruby script\generate model passenger".

b.) Create three new schema in mysql, they are taxiapp_production, taxiapp_development and taxiapp_test by MYSQl Query Browser.

c.) Edit the database.yml file which is located at C:\rails_apps\taxiapp\app\config by adding the root's password in development, test and production database configuration field. Please the below configuration:

development:
adapter: mysql encoding: utf8 database: taxiapp_development username: root password: 123456 host: localhost

test:
adapter: mysql encoding: utf8 database: taxiapp_test username: root password: 123456 host: localhost

production:
adapter: mysql encoding: utf8 database: taxiapp_production username: root password: 123456 host: localhost

d.) Edit C:\rails_apps\taxiapp\db\migrate\001_create_passengers.rb file with following statement

def self.up
create_table :passengers do t
t.column :name, :string
t.column :job_id, :integer
t.column :contact_number, :string
t.column :suburb_origin, :string
t.column :street, :string
t.column :street_number, :string
t.column :building, :string
t.column :suburb_destination, :string
t.column :passenger_number, :string
t.column :taxi_type, :string
t.column :date, :date
t.column :time_required, :time
end

e.) Create the table in taxiapp_production database by issuing the command "set RAILS_ENV=production" and then "rake db:migrate"

f.) Create the table in taxiapp_test database by issuing the command "set RAILS_ENV=test" and then "rake db:migrate"

g.) Create the table in taxiapp_development database by issuing the command "set RAILS_ENV=development" and then "rake db:migrate"

h.) Use MySQL query browser to check the table named passengers whether exits in taxiapp_test, taxiapp_production and taxiapp_development database.

From point d to h is telling you how to use the MVC “push-based architecture” in the Ruby on Rails development environment



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/

In this web site, it tells me how to use "scaffolding" to work with mysql. It is exactly same as my work in workshop 1.

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

It is a good tutorial web site for teaching me how to install and work with Rails.

沒有留言:

發佈留言