From workshop 3-part1, we have already created:
1.) A web application named taxiapp
2.) A model named passenger
3.) A table named passengers in taxiapp_test, taxiapp_production and taxiapp_development
Use of Scaffolding in online taxi booking system
I will try to use scaffolding in online taxi booking in this time.
1.) Install plugin named scaffold for online taxi booking system in the taxiapp directory by issuing the command [ruby script\plugin install scaffolding ]
2.) Install plug-in named paginate in the taxiapp directory by issuing the command
[ruby script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination]
REMARK: if the web site is not available, you can download the classic_pagination package from web and place it in yourApplicationDir\vendor\plugins\., or send a package request mail to me at samkwongfw@gmail.com
3. Install plugin named validates_date_time and date_time_text_field_helpers.
4.) Code generation of explicit controller and view for customizable interface by issuing the command in the taxiapp directory - "ruby script/generate scaffold passenger".
5.) Modify the controller file named passengers_controller.rb from using erb format to rhtml format, for example:
format.html # index.html.erb to format.html # index.rhtml
format.html # show.html.erb to format.html # show.rhtml
format.html # new.html.erb to format.html # new.rhtml
6.) Rename the view file from *.html.erb to *.rhtml.
7.) Configure Dreamweaver to support rhtml format in order to create a beautiful interface.
- Download Rybyweaver from http://rubtweaver.gilluminate.com/download
- Install rubweaver by double-click the mxp file, then, it will be automatically started the installer.
8.) Create a simple search engine for this web application
- In the model, defines a fuction with following code:
def self.search(search)
if search find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) else find(:all) end
end
- In the controller, tell it to use that search function in index page
@passengers = Passenger.search(params[:search])
- In the index page of view, call the search function in the defined interface with following code
text_field_tag :search, params[:search]
submit_tag "Search", :name => nil
9.) Create a Job ID auto-generator with following code
- @getResultSetJobID = Passenger.find(:all).last.job_id
- @newJobID = @getResultSetJobID+1 %>
10.) Define Input Validation in model
validates_date :date
validates_time :time_required
validates_presence_of :name,:contact_number,:suburb_origin,:street,:street_number,:suburb_destination,:message=>'Error Message: Field cannot be empty'
- 1. Create a new order - ok
- a.) Auto create the job ID -ok
- b.) Input Vaildation -k
- 2. Show the new order - ok
- 3. Edit the new order 0k
- 4. Search the new order ok
- 5. Destory the new order -ok
Please see the video for referance