I use MySQL Query Browser to execute the script to create a few databases including (OTBS, dev_OTBS and test_OTBS) and created each database a table, "passengers".
I generated the following script from MySQL Query Browser
CREATE TABLE 'otbs'.'passengers' (
'index' int(11) NOT NULL auto_increment,
'name' varchar(20) default NULL,
'job_id' varchar(5) default NULL,
'contact_number' int(8) default NULL,
'suburb_origin' varchar(15) default NULL,
'street' varchar(20) default NULL,
'street_number' int(4) default NULL,
'building' varchar(8) default NULL,
'suburb_destination' varchar(20) default NULL,
'passenger_number' int(1) default NULL,
'taxi_type' varchar(8) default NULL,
'Call_date' date default NULL,
'time_required' varchar(4) default NULL,
PRIMARY KEY ('index'))
ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
2.)Start "Manage Rails Applications..." from IR
3.)Create the Rails application by entering "rails -d mysql OTBS" at ..railapps>
4.)Hit "Refresh List", check OTBS and run "Start with mongrel"
5.)Test the connection by entering "http://127.0.0.1:3000/"
I need to copy "libmySQL.dll" from \mysql\bin\ to \ruby\bin\ to resolve the following error
I need to config "database.yml" to resolve the following error:
Mysql::Error in Rails/infoController#properties unknown database
Adding the following entries to "database.yml"
development: adapter: mysql encoding: utf8 database: dev_OTBS host: localhost username: root password:
test: adapter: mysql encoding: utf8 database:test_OTBS host: localhost username: root password:
production: adapter: mysql encoding: utf8 database: OTBS host: localhost username: root password:
6.)Create Model for Passenger by typing "ruby script/generate model passenger" at ..railapps\OTBS>
7.)Create Controller for Passenger by typing "ruby script/generate controller passenger" at ..railapps\OTBS>
8.)Install "Scaffold" plugin to create a set controller methods for CRUD operations of OTBS by typing "ruby script/plugin install scaffolding" at ..railapps\OTBS>
9.)Install paginate plugin to work with Scaffolding by typing "ruby script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination"
However, this is not very easy to get it installed on your machine based on my experience. First of all, you need to unblock the snv connection from the firewall of your machine. Secondly, the connection is not very stable and get time out very often. Therefore, I switch to another plugin, "Will_paginate". You can download it from the following website. Unfornately, it doesn't work my version of Ruby (1.8.6). Please don't attempt!
http://github.com/mislav/will_paginate/tree/master
10.)Modify the controller of "passenger" (i.e. passenger_controller.rb) by adding "
scaffold:passenger" (Aptana is a good programming tool!)
11.)Test the connection by entering "http://127.0.0.1:3000/passenger" Geat! I can get it to work eventually. It takes me a week to work it out.
I use Mongrel instead of WEBrick even through most of Ruby tutorials are using WEBrick.
I qouted the definition from (trac n.d.)
What is Mongrel?
Mongrel is a fast HTTP library and server for Ruby that is intended for hosting Ruby web applications of any kind using plain HTTP rather than FastCGI or SCGI. It is framework agnostic and already supports
Ruby On Rails, Og+Nitro, Camping, and IOWA frameworks. Mongrel was originally written by Zed A. Shaw.Trac n.d., What is Mongrel, <http://mongrel.rubyforge.org/>.
No comments:
Post a Comment