Answer:
Now, I will create a single model, view and controller classes in my home PC. The Diagram-36 shows the Taxi project starts after issuing "rails taxi" command.
The Taxi project is created. The I run "ruby script/server" to make the Taxi Project available on the web at tcp port 3000. The Diagram-37 shows the result of running "ruby script/server" command.
Diagram-37 - Taxi Project starts at tcp port 3000
Next, I run "ruby script/generate model Taxi" to generate Taxi Active Record. The Diagram-38 shows the result of running the ruby command. You can find that the taxi.rb file is created. The next Diagram-39 show Taxi class and the related attributes of Taxi class are defined in taxi.rb file.
Diagram-38 - taxi.rb is created (single model)
Diagram-39 - Taxi class is defined in taxi.rb file
In Taxi class, taxinum and taxidrv attributes are defined. They represents taxi number and taxi driver name respectively.
After the single Taxi model (active record) is created, I issue "ruby script/generate controller Taxi" command to create Taxi controller methods in taxi_controller.rb file. The Diagram-40 and Diagram-41 show the taxi_controller.rb is created and the controller methods in taxi_controller.rb file respectively.
Finally, we can simply use text editor, namely, edit.exe in MS-DOS, to create a view file located in app\views\taxi subdirectory, for example, list method defined in active controller. The diagram-42 shows the view of list method and in fact the list method is displayed as list.rhtml or list.html.erb file (html with embedded Ruby code).
Diagram-42 - list.html.erb (View in MVC approach)
I have applied the MVC design approach to create a single view, controller and model successfully.
No comments:
Post a Comment