Friday, May 21, 2010

Workshop 8


1. List what you consider to be the three strengths of Ruby on Rails workshop series
I consider the 3 strengths to be:
    • Ruby on Rail is step by step and clear guiding workshop to make a effective learning method.
    • We can learn Model–View–Controller (MVC) from workshops and describe how to use MVC .
    • Ruby on Rails is an open source web application framework that has database, application server, and programming environment.
2. List what you consider to be the three weaknesses of Ruby on Rails workshop series:
I consider the 3 weaknesses to be:
    • There was some dead link in workshop provided tutorial.
    • There was a gap between RED team (Developer) and BLUE team (IT Infrastructure Manager).
3. List what aspects of Ruby on Rails workshop series that you found to be most difficult.
The most difficult aspects were:
    • To setup the Ruby on Rails version compatibility.
    • To identify with the MVC architecture in Ruby on Rails.
4. List what improvements could be made to the Ruby on Rails workshop series:
Improvements I would make include:
    • Check the tutorial link and source code whether is workable
    • discuss and analyse the Mobile Web service framework technologies with Ruby on Rails
5. Reflect on your experiences with the other Web framework used in this subject: Was it effective? How can it be improved? Should other Web frameworks be used as well or instead of Ruby on Rails?
First of all I have an experience on using ruby on Rail,Microsoft.net,SQL Server and so on.It is effective and good to study a new technology.
6. Did the Developer’s or IT managers Team that you joined after workshop 4 have a preference towards using other tools to facilitate collaboration? Comment on the differences between these use of the sub-forum or Interact wiki tools from your experiences in this subject.
As I work in Developer’s team and the communication and collaboration were important during the workshops.
7. Further comments to add?
Thank you to all friend.

Workshop 7


Developers conclude their work with the OTBS and look at the options for deployment of the site. Examine the various platforms/software tools used for deployment such as UNIX environment suggested in the Discussion Notes, Mongrel or Mongrel cluster, Nginx, Subversion or Capistrano (during development stage), JRuby in the Java environment.

Which way?

The choice is up to you as this workshop present just one option and you may like to use another, such as deploying the OTBS in a .NET or J2EE environment
For my Online Taxi Booking System (OTBS), I install Ruby on Rails 1.8.6-26 and Rubygems 1.3.2 in my windows server 2003.
In Ruby on Rails development, i would like to use “rake” to generate the database table and use scaffolding to generate the view page. It is very powerful for Rapid application development.
Then, I feel Ruby on Rails is very suitable for SQL operation, because the simplest datbase operations are often described as CRUD (Create, Rad, Update and Desctroy).


Can you get the OTBS Running in production mode as a minimal production server?
As a minimal production server:
  • Using Mongrel / Linux OS / Apache Web server, as the Rails application server
  • Setup the same softwares (such as Ruby, Rails, database and plugins) on the server like the development computer
  • Upload the Rails project to the server, follow the deploy application steps at the above to create and configure the production database
  • Install and configure the application server and webserve

Thursday, May 20, 2010

Workshop 6


Ajax stand for asynchronous JavaScript and XML and it is a group of interrelated web development techniques used on the client-side to create interactive web applications. With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behaviour of the existing page.
Jesse James Garrett explained that the following technologies are required:
  • HTML or XHTML and CSS for presentation
  • the Document Object Model for dynamic display of and interaction with data
  • XML and XSLT for the interchange, and manipulation and display, of data, respectively
  • the XMLHttpRequest object for asynchronous communication
  • JavaScript to bring these technologies together
JavaScript is not the only client-side scripting language that can be used for implementing an Ajax application. Other languages such as VBScript are also capable of the required functionality. However JavaScript is the most popular language for Ajax programming due to its inclusion in and compatibility with the majority of modern web browsers.
XML is not required for data interchange and therefore XSLT is not required for the manipulation of data. JavaScript Object Notation (JSON) is often used as an alternative format for data interchange, although other formats such as preformatted HTML or plain text can also be used.
Rails has a simple, consistent model for how it implements Ajax operations. Once the browser has rendered and displayed the initial web page, different user actions cause it to display a new web page or trigger an Ajax operation:
  • A trigger action occurs. This could be the user clicking on a button or link, the user making changes to the data on a form or in a field, or just a periodic trigger (based on a timer).
  • Data associated with the trigger (a field or an entire form) is sent asynchronously to an action handler on the server via XMLHttpRequest.
  • The server-side action handler takes some action (that’s why it is an action handler) based on the data, and returns an HTML fragment as its response.
  • The client-side JavaScript (created automatically by Rails) receives the HTML fragment and uses it to update a specified part of the current page’s HTML, often the content of a

    tag.
Rails has several helper methods for implementing Ajax in your view’s templates. One of the simplest yet very versatile methods is link_to_remote (). Consider a simple web page that asks for the time and has a link on which the user clicks to obtain the current time. The app uses Ajax via link_to_remote () to retrieve the time and display it on the web page.
Reference:-
Wikipedia 2010, Ajax (programming), last modified 23 Apr 2010, viewed 29 Apr 2010, http://en.wikipedia.org/wiki/Ajax_(programming)

Workshop 5


Part A: Viewing the action


  1. Create the Rails application framework in the projects folder: C:\InstantRails\...\projects\>rails animals

C:\Ruby>rails animal
      create
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  config/initializers
      create  config/locales
      create  db
      create  doc
      create  lib
      create  lib/tasks
      create  log
      create  public/images
      create  public/javascripts
      create  public/stylesheets
      create  script/performance
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance
      create  test/unit
      create  vendor
      create  vendor/plugins
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  Rakefile
      create  README
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  config/database.yml
      create  config/routes.rb
      create  config/locales/en.yml
      create  db/seeds.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/initializers/session_store.rb
      create  config/environment.rb
      create  config/boot.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  script/about
      create  script/console
      create  script/dbconsole
      create  script/destroy
      create  script/generate
      create  script/runner
      create  script/server
      create  script/plugin
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  test/test_helper.rb
      create  test/performance/browsing_test.rb
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/images/rails.png
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  doc/README_FOR_APP
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log


  1. Running  the application on localhost:3000 using the WeBrick ruby server (or Mongrel as alternative) and access via Web browser at http://localhost:3000/




















    3. Create the controller to make the application do an action. This is under the controller-action/model-view structure.

    Stop the WEBrick server each time you edit Ruby classes and then re-start or refresh the views you are testing. Use the Ruby command below:

    >ruby script/generate controller Mammal

    C:\animals>ruby script/generate controller Mammal
          exists  app/controllers/
          exists  app/helpers/
          create  app/views/mammal
          exists  test/functional/
          create  test/unit/helpers/
          create  app/controllers/mammal_controller.rb
          create  test/functional/mammal_controller_test.rb
          create  app/helpers/mammal_helper.rb
          create  test/unit/helpers/mammal_helper_test
    5. Create an action by editing and saving the mammal_controller.rb class in projects\animals\app\controllers using your text editor to add the method below:

    class MammalController< ApplicationController
       def breathe
       end
    end
     









    7. Create and save a view in that directory by using a text editor to create a view called breathe.rhtml

    <html>
                <head>
                   <title>Breathe Easytitle>
                head>
                <body>Inhale and Exhale
                body>
    html>

    8. Try Ruby code and HTML in the action view by using the <%....%> wrapper around the inserted Ruby code. Here are some snippets to try from workshop 4:
    <br>
    5 + 6 =<%= 5 + 6 %>
    br>
    <br>
    =<% 4.times do %>
    Inhale Exhale <br>
    <%end%>
    <br>
    Time is <%=Time.now %>
    br>
     
    Part B: The active view: passing data from an action too a view

    1. Create a new application called scenery in the same projects directory to demonstrate the use of an active view.

    > rails scenery
    > cd scenery

    C:\Ruby>rails scenery
          create
          create  app/controllers
          create  app/helpers
          create  app/models
          create  app/views/layouts
          create  config/environments
          create  config/initializers
          create  config/locales
          create  db
          create  doc
          create  lib
          create  lib/tasks
          create  log
          create  public/images
          create  public/javascripts
          create  public/stylesheets
          create  script/performance
          create  test/fixtures
          create  test/functional
          create  test/integration
          create  test/performance
          create  test/unit
          create  vendor
          create  vendor/plugins
          create  tmp/sessions
          create  tmp/sockets
          create  tmp/cache
          create  tmp/pids
          create  Rakefile
          create  README
          create  app/controllers/application_controller.rb
          create  app/helpers/application_helper.rb
          create  config/database.yml
          create  config/routes.rb
          create  config/locales/en.yml
          create  db/seeds.rb
          create  config/initializers/backtrace_silencers.rb
          create  config/initializers/inflections.rb
          create  config/initializers/mime_types.rb
          create  config/initializers/new_rails_defaults.rb
          create  config/initializers/session_store.rb
          create  config/environment.rb
          create  config/boot.rb
          create  config/environments/production.rb
          create  config/environments/development.rb
          create  config/environments/test.rb
          create  script/about
          create  script/console
          create  script/dbconsole
          create  script/destroy
          create  script/generate
          create  script/runner
          create  script/server
          create  script/plugin
          create  script/performance/benchmarker
          create  script/performance/profiler
          create  test/test_helper.rb
          create  test/performance/browsing_test.rb
          create  public/404.html
          create  public/422.html
          create  public/500.html
          create  public/index.html
          create  public/favicon.ico
          create  public/robots.txt
          create  public/images/rails.png
          create  public/javascripts/prototype.js
          create  public/javascripts/effects.js
          create  public/javascripts/dragdrop.js
          create  public/javascripts/controls.js
          create  public/javascripts/application.js
          create  doc/README_FOR_APP
          create  log/server.log
          create  log/production.log
          create  log/development.log
          create  log/test.log

    C:\Ruby> cd scenery

    C:\Ruby\scenery>
    2. Create a controller called Demo in scenery\app\controllers

    scenery> ruby script/generate controller Demo





















    3. Add an action to demo_controller.rb as the method called rubycobe

    class DemoController< ApplicationController
       def rubycode
       end
    end























     









    4. Add a view template - scenery\app\views\demo\rubycode.rhtml
    We will edit this view in later steps but you may like to add your own test HTML code to the view at this stage.

    5. Save and restart the Web server and navigate to http://localhost:3000/scenery/rubycode
                  
                      Ruby Code
          
    6. Use the Time.now example to pass data from an action to a view. 

     
    7. Modify and save the rubycode action with a value for the time instance variable in the DemoController class in app\controllers\demo_controller.rb

    class DemoController< ApplicationController
       def rubycode
                 @time_now = Time.now
       end
    end

    8. Then modify and save the corresponding view template in \app\views\demo\rubycode.rhtml by adding a call by reference to the action’s instance variable:


    The time is <%= @time.now %>

         

    9. Restart the Web server and navigate the browser to http://localhost:3000/demo/rubycode
                 
               

    Part C: Screen layouts and forms processing with text fields, check boxes, radio buttons and multiple list controls


    1. Create a new application called cabs in the same projects directory to demonstrate the use of an active view.

    > rails cabs
    > cd cabs
    C:\>rails cabs
          create
          create  app/controllers
          create  app/helpers
          create  app/models
          create  app/views/layouts
          create  config/environments
          create  config/initializers
          create  config/locales
          create  db
          create  doc
          create  lib
          create  lib/tasks
          create  log
          create  public/images
          create  public/javascripts
          create  public/stylesheets
          create  script/performance
          create  test/fixtures
          create  test/functional
          create  test/integration
          create  test/performance
          create  test/unit
          create  vendor
          create  vendor/plugins
          create  tmp/sessions
          create  tmp/sockets
          create  tmp/cache
          create  tmp/pids
          create  Rakefile
          create  README
          create  app/controllers/application_controller.rb
          create  app/helpers/application_helper.rb
          create  config/database.yml
          create  config/routes.rb
          create  config/locales/en.yml
          create  db/seeds.rb
          create  config/initializers/backtrace_silencers.rb
          create  config/initializers/inflections.rb
          create  config/initializers/mime_types.rb
          create  config/initializers/new_rails_defaults.rb
          create  config/initializers/session_store.rb
          create  config/environment.rb
          create  config/boot.rb
          create  config/environments/production.rb
          create  config/environments/development.rb
          create  config/environments/test.rb
          create  script/about
          create  script/console
          create  script/dbconsole
          create  script/destroy
          create  script/generate
          create  script/runner
          create  script/server
          create  script/plugin
          create  script/performance/benchmarker
          create  script/performance/profiler
          create  test/test_helper.rb
          create  test/performance/browsing_test.rb
          create  public/404.html
          create  public/422.html
          create  public/500.html
          create  public/index.html
          create  public/favicon.ico
          create  public/robots.txt
          create  public/images/rails.png
          create  public/javascripts/prototype.js
          create  public/javascripts/effects.js
          create  public/javascripts/dragdrop.js
          create  public/javascripts/controls.js
          create  public/javascripts/application.js
          create  doc/README_FOR_APP
          create  log/server.log
          create  log/production.log
          create  log/development.log
          create  log/test.log
    C:\>cd cabs
    C:\cabs>
    2. Create a controller called Vehicle in cabs\app\controllers

    cabs> ruby script/generate controller Vehicle


    3. Add an action to vehicle_controller.rb as the method called cabtype

    class VehicleController< ApplicationController
       def cabtype
       end
    end
    4. Add a view template - cabs\app\views\vehicle\cabtype.rhtml
    We will edit this view in later steps but you may like to add your own test HTML code to the view at this stage.


    6. Create a file in the public directory - \cabs\public called input.html
















    7. Edit the vehicle_controller.rb here is a start. The data in each form element in the Rails application can be accessed via its name and a hash called params

    class VehicleController< ApplicationController
       def cabtype
         @data1 = params[:text1]
         @data2 = params[:check1]
    @data3 = params[:radios1]
    @data4 = params[:building1]
       end
    end