To do:
1. Set up a focus group (like a study group for peer learning) to work on the Ruby on Rails workshops via Interact tools as a class.
I have set up a study group called Team 007 in Wiki took, at CSU’s Interact Intracnet.
2. What is meant by “convention over configuration” and how does it reduce coding?
From the Wiki definition, Convention over Configuration (CoC) is a ‘software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.’
CoC reduce coding by relating the database to the class by default, e.g. the corresponding table in a table with the class ‘Sale’ will be automatically named as ‘Sale’. Unless there is exception, then needs to be specified.
3. Further work on understanding MVC:
a. See the wiki at
http://wiki.rubyonrails.org/rails/pages/UnderstandingMVC
Error message ‘This topic does not exist’
b. Do the MVC tutorial at http://wiki.squeak.org/squeak/1767
The tutorial described the origin of MVC.
4. Got a spare hour or so? I recommend the UC Berkeley RAD lab’s Ruby on Rails Short course at http://youtube.com/watch?v=LADHwoN2LMM
How can this guy keep speaking that fast?
References
Wikipedia. (2009). Convention over Configuration. Retrieved on 26 March 2010, from http://en.wikipedia.org/wiki/Convention_over_configuration
Challenge Problems:
1. How is Rails structured to follow the MVC pattern?
Consider our project and examine the directories where Rails is located. If the data model is called Taxi (it is convention to name the model beginning with an upper case letter).
The model is a Ruby class located in app/models/taxi.rb
The SQL table is taxis – the pluralisation of the model. In our project we have 2 tables as passenger_origin and passenger_destination, where the table row = an object instance and each of the columns = an object attribute.
The controller methods live in app/controllers/taxi_controller.rb
Each controller can access templates to display the input screen and methods for action.
The views are kept is app/views/taxi/*.rhtml, where each *.rhtml maps to a controller method.
In Rails, the view is rendered using RHTML or RXML. According to the wiki page at http://wiki.rubyonrails.org/rails/pages/UnderstandingViews, RHTML is HTML with embedded Ruby code and RXML is Ruby-generated XML code.
From the Wiki, Rails use the Model-View-Controller (MVC) architecture as a design framework. (Wiki, 2010) When an application is created, the data of a specific application (like the Taxi) is stored in a directory structure with folder 'app/controllers', 'app/views' and 'app/models'
More about the directory structure is set up. Below is the example extracted from a RoR tutorial. (Ruby on Rails 2.1.x - Directory Structure, n.d.)
The application is called demo, steps below.
C:\ruby\> rails -d mysql demo
Now go into demo application root directory as follows:
C:\ruby\> cd demo
C:\ruby\demo> dir
You will find a directory structure as follows:
demo/
..../app
......../controller
......../helpers
......../models
......../views
............../layouts
..../config
..../db
..../doc
..../lib
..../log
..../public
..../script
..../test
..../tmp
..../vendor
README
Rakefile
References
Tutorial Points. (n.d.).Ruby on Rails 2.1.x - Directory Structure. Retrieved on 26 March 2010 from http://www.tutorialspoint.com/ruby-on-rails-2.1/rails-directory-structure.htm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment