Saturday, March 21, 2009

Workshop 4: Riding the Rails with Ruby - Challenge Problem: 2

Write a Ruby program called fizzbuzz.rb that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Workshop 4: Riding the Rails with Ruby - Challenge Problem: 1

Create, test and debug a Ruby program called dognames.rb or catnames.rb to accept 3 names from the keyboard and to display each name on the screen in alphabetical order WITHOUT using a data structure such as a list.

Workshop 4: Riding the Rails with Ruby - To do: 3

While Ruby and Python are quite similar, can you find some similarities between Ruby and Javascript?

Workshop 4: Riding the Rails with Ruby - To do: 2

What are the syntax differences in the way that Ruby and Javascript use the if statement?

Workshop 4: Riding the Rails with Ruby - To do: 1

Spend some time moving your way through the 46 Ruby coding examples in the Ruby Tutorial with Code from http://www.fincher.org/tips/Languages/Ruby/

Workshop 3: Online Taxi Booking System: MySQL and Database design - To do: 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/

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

Workshop 3: Online Taxi Booking System: MySQL and Database design - To do: 4

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

Workshop 3: Online Taxi Booking System: MySQL and Database design - To do: 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.

Workshop 3: Online Taxi Booking System: MySQL and Database design - To do: 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).

Workshop 3: Online Taxi Booking System: MySQL and Database design - To do: 1

Set up the MySQL tools on your computer as described in section 6 above.

Workshop 2: Model View Controller design approach - Challenge Problems: 2

Apply the MVC design approach to our Project: Online Taxi Booking System.

HINT: Begin with a single model, single view and single controller classes. This will give you a head start to the next workshop: Online Taxi Booking System: SQL and Database design

Workshop 2: Model View Controller design approach - 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.

Workshop 2: Model View Controller design approach - 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.

Comments and Suggestions

Please place your comments & suggestions here....

Thank you !

Workshop 2: Model View Controller design approach - To do: 5

Read the Flash article using ActionScript by Colin Moock titled “The Model-View-Controller Design Pattern “at http://www.adobe.com/devnet/flash/articles/mv_controller.html

Workshop 2: Model View Controller design approach - To do: 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

Workshop 2: Model View Controller design approach - To do: 3

Further work on understanding MVC:

a. See the wiki at http://wiki.rubyonrails.org/rails/pages/UnderstandingMVC

b. Do the MVC tutorial at http://wiki.squeak.org/squeak/1767

Workshop 2: Model View Controller design approach - To do: 2

What is meant by “convention over configuration” and how does it reduce coding?

Workshop 2: Model View Controller design approach - 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.

Workshop 1: Setting up model railway - Challenge Problems: 6

Describe the steps involved with the MVC design approach.

Workshop 1: Setting up model railway - Challenge Problems: 5

When did Model-View-Controller begin and where is it used?

Workshop 1: Setting up model railway - Challenge Problems: 4

What is meant by “convention over configuration” in regards to the use of Rails in Web application development?

Workshop 1: Setting up model railway - Challenge Problems: 3

What is Rails and how does it work with Ruby?

Workshop 1: Setting up model railway - Challenge Problems: 2

Ruby is “an interpreted scripting language” for quick and easy object-oriented programming”. Find out about the Ruby language and discover what this means.

Workshop 1: Setting up model railway - Challenge Problems: 1

Make a list of all programming languages and Web development tools used by you in prior experiences. Describe what you know about Web application frameworks before we begin.

Workshop 1: Setting up model railway - To do: 3

Rather than get Ruby on Rails running manually, you use the pre-packaged solutions. These include everything in one bundle: Web server, database, Ruby, Rails, the works.

a. For OS X, there's Locomotive.

b. For Windows, there's Instant Rails.

Workshop 1: Setting up model railway - To do: 2

Install Ruby on Rails on your computer by using the material and downloads from http://www.rubyonrails.org/

Workshop 1: Setting up model railway - To do: 1

Download iTunes from http://www.apple.com/itunes/download/ and subscribe to the “Leraning Rails” Podcasts from http://www.buildingwebapps.com/podcasts