1. Download iTunes from http://www.apple.com/itunes/download/ and subscribe to the “Leraning Rails” Podcasts from http://www.buildingwebapps.com/podcasts
I do not need to install the iTunes, as my Mac already bundled with the iTunes.
I had subscript the LearningRails free online Ruby on Rails course at http://www.buildingwebapps.com/podcasts
There are total 23 lessons in the learning Rails Podcasts. I receive the mail notice regularly from LearningRails that remind me to take the lesson one by one.
2. & 3. Setup Ruby on Rails in my MacBook Pro
I had spent 2 days to complete the setup of the Rails in my MacBook Pro. I have used Mac for only half year, before that I use Windows only.
I follow the steps in Website: Setup up Rails on Leopard (Mac OS X 10.5)
to setup the Ruby on Rails
The installation of Rails is not so smooth, the installer of MacPorts suspended in the middle of the process and finally could not be successfully complete. At last, I used the manual procedure to install it.
After successful install of MacPorts, I cannot start the Mysql. I had tried the installation statements for many times, Mysql still cannot be started. Finally, I found out the problem is missing the two statements change in the “my.cnf” file.
Thanks god, Mysql is working.

Oh! the Rails cannot start for the outdated version of Rails Gems. I go to the installation Web page for the Setup of Rails on Tiger (Mac OS X 10.4), reinstall the Ruby, Ruby Gems and Git. Finally, Rails can be run.
In the iTerm, type 'rails testApp' to create the project named 'testApp'

In the iTerm, type 'cd testApp', then 'ruby script/server' to start the Web server

Go into the Web browser, type 'http://localhost:3000/' to browse the Web site of 'testApp'

Ruby on Rails is working in my Mac, Thanks.
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.
Programming languages and Web development tools used by me list:
- Pascal
- Cobol
- RPG AS400
- Microsoft Foxpro
- Visual Basic .Net
- Java
- HTML
- JavaScript
- C
- Security - enable web server to identify the users of the application
- Database access and mapping - a unified API to database backend, enabling web application to work with varity of database
- Caching - reduce bandwidth usage and server load.
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.
Ruby is an interpreted scripting language as it does not have compiler. We simply pass the plain text script into Ruby to processes it on the fly, bypasses the compilation step. "Ruby scripts are far more portable and more flexibility, as it can perform incredible feats of agility that leave compiled languages sitting on the sideline staring open mouthed in disbelief" said by (Alameda 2008, P.15). Ruby code is able to be far more dynamic and even enhance itself at runtime (Alameda, 2008).
In Ruby everything is an object. Alameda (2008, P.15) said that 'Ruby brings forth a completely unified vision of how object orientation within a programming language should be'. In object orienation programming (OOP), each object has its own unique attributes, and each object is able to interact and communicate with other objects. We first define a class, before creating an object. A new instances of an object is created by class. Generic properties and methods are defined in each class, that will be shared among all instances of that class. We use methods to represent things that an object can do. All of the above OOP attributes are implemented in Ruby (Alameda, 2008).
Coding the class in Ruby:
class Cat
attr_accessor :name, :breeed
def cry
puts "mi mi"
end
def wag_tail
puts "Wagging Tail"
end
end
Coding of create a new instance in Ruby using new keyword:
catA = Cat.new
Coding of using setter methods that were created to set catA's properties:
catA.name = "MiMi"
catA.breed = "Burmese cat"
Coding of call the methods that created to interact with our new cat:
catA.cry # mi mi
catA.name # "MiMi"
catA.wag_tail # wagging tail
3. What is Rails and how does it work with Ruby?
Rails is an add-on to the Ruby. Rails contains a library that full of Ruby code and scripts for generating parts of applications. Most likely, Ruby framework is an add-on to the Ruby programming language. Rails is lightweight and nimble frameworks used to solve the Web and database problem in Ruby (Burd, 2007). Burd claims that write a Rails application in one-tenth the time it takes to write the same application using a heavyweight frameworks. He also said that Rails is built on the principles: 1. convention over configuration and 2. Don't Repeat Yourself (DRY).
4. What is meant by “convention over configuration” in regards to the use of Rails in Web application development?
"convention over configuration" is one of the Rails' built on principles. A Web application is combine from many parts, and you can connecting them in anyways. A way to deal with parts of an application that names like picture and image bear little relation to one another. The programmer hook the application's parts together using a configuration file. It is confusing if the configuration file encodes with different facts such as "variable picture reads data from column image", "variable quotation reads data from column stock_value" or "variable comment_by_expert" reads data from column quotation. Programmer spend hours writing configuration files and specifying complex chains of names. The result of errors creep into the system, spend more hours chasing bugs. Rails avoid configuration in favor of naming conventions. In Rails variable named image matches automatically with a column of the same name in the database table, this is called "convention over configuration". Most of the configuration files are completely unnecessary in Rails.
5. When did Model-View-Controller begin and where is it used?
Model-View-Controller (MVC) pattern was originally designed for the structuring code of applications that have a graphical user interface stated by (Alameda, 2008). Although it is often implemented in slightly different ways, the core idea of MVC is to separate the code into 3 distinct areas of responsibility. Ruby on Rails helps to keep the Web applications organized through its implementation of the MVC pattern.
MVC use in 1. code that controls or manipulates the data associated with the application or stores business logic for validation or formatting of data will be stored in the Model layer. 2. The HTML templates are eventually displayed to the end user in respone to a web request would be stored within the View layer. Finally, 3. the Controller layer where we store the code that responds to user's request by interacting with models to obtain the correct data and choosing which view to render in response (Alameda, 2008).
6. Describe the steps involved with the MVC design approach.
The different parts of the MVC pattern used in the Rails request-response cycle show in the figure from (Alameda, 2008):

The following steps occur in response to a request for a Web page:
- receive a new request for a Web page to our Rails application
- Rails routes the request to a controller for processing
- controller interacts with the models in the application to gather the necessary data
- model classes may retrieve or insert data into database
- once models have generated or retrieved the correct information, will return the data back to the controller
- the controller collects all of the data it's received from the models and selects a view template to render
- the view template is rendered using the data that controller gathered and handed to the Web server.
- An HTML page is returned to the user
Reference
- Alameda, A. (2008), Foundation rails 2, Springer-Verlag New York, Inc.
- Burd, B. (2007), Ruby on rails for dummies, Wily Publishing, Inc.
- McGregor, K. (2007), Web Application Framework, Retrieved from http://www.articlesbase.com/internet-articles/web-application-framework-197026.html on 17th Mar, 2009.
- Wikipedia (N.A.), Web application frameword, Retrieved from http://en.wikipedia.org/wiki/Web_application_framework on 17th Mar, 2009.
No comments:
Post a Comment