Friday, April 24, 2009

Week 11: Rails Passion Course

  1. Week 11: Action Controller Basics (Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed on request and then either render a template or redirect to another action. An action is defined as a public method on the controller, which will automatically be made accessible to the web-server through Rails Routes.
    Topics to be covered: What is ActionController?, ActionController classes, Request handling, Parameters, Session & Flash, Rendering, Redirection, Classic problem of user refresh & redirection, Routing (request mapping))
  2. 5526_rails_controller.zip (Unzip it in a directory of your choice and read lab document from /rails_controller/index.html to proceed) (4/24/09: Downloaded)
  3. Week 11 Resources
    o Basics
    + Action Pack from api.rubyonrails.org
    + ActionController::Base API from api.rubyonrails.org
    + ActionController::Flash API from api.rubyonrails.org
    o Routing
    + ActionController::Routing API from api.rubyonrails.org
    o Caching
    + ActionController::Caching API from api.rubyonrails.org
  4. Presentation - PDF: 1 slide per page (OR) OpenOffice file (47 pages) (4/27/2009: Done)
  5. Online Lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (93 pages)
  6. EXERCISE 0: Start MySQL database server. (p.2)
  7. EXERCISE 1: Requests and Parameters I (p.2-15)
  8. (1.0) Open and run "helloworld" sample application (p.2-4)
  9. (1.1) Observe parameters in development log. (p.4-6)
  10. (1.2) Modify the controller (p.6-9)
  11. (1.3) Pass the parameters through URL (p.9-11)
  12. (1.4) Observe the parameters in development log (p.11-12)
  13. (1.5) Observe the controller and action parameters (p.12-16) PROBLEM: :action not displayed. The fix was to rename ":action_name" to ":action1_name"
  14. EXERCISE 2: Request and Parameters II (p.16-34)
  15. (2.0) Open and run "helloname" sample application project. (p.16-19)
  16. (2.1)Observe parameters in development log. (p.19-22)
  17. (2.2) Study how user input data is collected as parameters (p.22-25)
  18. (2.3) Study how parameters are accessed in the controller (p.25-26)
  19. (2.4) Add another column to the table through migration (p.26-30)
  20. (2.5) Modify the code of index.html.erb and respond.html.erb files. (p.30-31)
  21. (2.6) Run the helloname application. (p.31-33)
  22. (2.7) Observe the parameters in development log. (p.33-34)
  23. EXERCISE 3: Session and Flash (p.34-63)
  24. (3.1) Use session. (p.34-40)
  25. (3.2) Use ActiveRecordStore to maintain session data (p.40-56)
  26. (3.3) Use Flash (p.56-63)
  27. EXERCISE 4: Rendering (p.63-72)
  28. (4.1) Use render :text (p.64-66)
  29. (4.2) Use render :action => :respond (p.66-68)
  30. (4.3) Use render :action => 'respond" (p.68-70)
  31. (4.4) Use render :template (p.70-72)
  32. EXERCISE #5: User refresh problem with "render" - Use "redirect_to" (p.72-87)
  33. (5.1) Observe the problem of using render :action=>'list' when a user press "Refresh" (p.73-80)
  34. (5.2) Correct the problem by using redirect :action=>'list' instead (p.80-87)
  35. EXERCISE #6: Routing Basics (p.87-
  36. (6.1) Use Rails Console (for routing experimentation) (p.87-88)
  37. (6.2) Named routes (p.88-92)
  38. Homework


Tuesday, April 21, 2009

Week 10: Rails Passion Course

  1. Week 10: ActiveRecord Associations Basics (Topics covered: What is an Association?, Auto-generated methods, Cardinality, Unsaved objects and association)
  2. Week 10 Resources
    o ActiveRecord::Associations:ClassMethods API from api.rubyonrails.org
    o Building Relationships Between Rails Models tutorial by Brian Leonard and Gail Chappell
  3. 5525_rails_associations.zip (Unzip it in a directory of your choice and read lab document from /rails_associations/index.html to proceed) (4/21/09: Downloaded)
  4. Presentation - PDF: 1 slide per page (OR) OpenOffice file (22 pages)
  5. Online Lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (84 pages)
  6. EXERCISE #0: Start MySQL database server (p.g2) (4/21/2009: done)
  7. EXERCISE #1: Add one-to-many association to rubyweblog application. (p.2-28)
  8. (1.1) Create Comment Model class (p.3-6)
  9. (1.2) Migrate database (p.6-7)
  10. (1.3) Add association macros to the Model classes (p.8-11)
  11. (1.4) Modify controller (p.11-15)
  12. (1.5) Modify [view] templates (p.15-17)
  13. (1.6) Save the changes (p.17-18)
  14. (1.7) Refresh the browswer and perform user operation (p.19-21)
  15. (1.8) Observing the database tables (p.22-26)
  16. (1.9) Use Rails Console (p.26-28)
  17. EXERCISE #2: Options for has_many (p.28-46)
  18. (2.0) Create fresh test data using migration (p.28-33)
  19. (2.1) Exercise :order option (p.34-39)
  20. (2.2) Exercise :destroy option (p.39-46)
  21. EXERCISE #3: Add many-to-many association to rubyweblog application (p.46-65)
  22. (3.1) Create Category model class (p.46-49)
  23. (3.2) Create "categories_posts" table through migration (p.49-55)
  24. (3.3) Add many-to-many relationship between Post and Category models (p.55-58)
  25. (3.4) Create test data through migration (p.59-64)
  26. (3.5) Use Rails Console (p.64-65)
  27. EXERCISE #4: Add many-to-many association to rubyweblog application using through - not ready yet
  28. (4.1) Recreate rubyweblog_development database (p.66-68)
  29. (4.2) Remove migration files that are not needed (p.68-69)
  30. (4.3) Create a join model (p.70-73)
  31. (4.4) Modify Post and Category models (p.73-75)
  32. (4.5) Create test data through migration (p.75-79)
  33. (4.6) Verify that the data tables are created correctly (p.79-83)
  34. (4.7) Use Rails Console (p.83-84)
  35. Finished Exercises (4:30pm)
  36. Homework (p.84)

Sunday, April 19, 2009

Week 9: Rails Passion Course

  1. Week 9: ActiveRecord Basics (Topics covered: What is Active Record?, Active Record Object Creation, Find operation, Dynamic Attribute-based Finders, Validation, Migration, Callbacks, Exception Handling)
  2. Week 9 Resources
    1. Basics
      1. ActiveRecord from api.rubyonrails.org
      2. ActiveRecord::Base API from api.rubyonrails.org
      3. ActiveRecord tutorial screencast by Gregg (July 2007)
      4. Advanced ActiveRecord presentation by Obie Fernandez
    2. Validation
      1. ActiveRecord::Validations::ClassMethods API document from rubyonrails.com
      2. Various examples from railsbrains.com
    3. Migration
      1. ActiveRecord::Migration API document from railsbrains.com
      1. Generate a migration from an existing MySQL database posting in ruby-forum.com
  3. 5522_rails_activerecord.zip (Unzip it in a directory of your choice and read lab document from /jrubyrails_basics/index.html to proceed) (4/19/09: Downloaded)
  4. Presentation --PDF: 1 slide per page (OR) OpenOffice file (44 pages) (4/21/09: Read)
  5. Online Lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (105 pages)
  6. EXERCISE #0: Start MySQL database server. (p.2)
  7. EXERCISE #1: Creation of ActiveRecord Objects (p.2-39)
  8. (1.1) Create a new NetBeans project (with JRuby 1.1.4 and WEBrick) (p.3-6)
  9. (1.2) Create database (p.6-7)
  10. (1.3) Generate Model (3 attributes) (p.8-10)
  11. (1.4) Create database table through migration (p.10-19)
  12. (1.5) Create ActiveRecord objects through Rails Console (p.20-28)
  13. (1.6) Create database table rows through migration (p.29-39)
  14. EXERCISE #2: ActiveRecord#find (p.40-44)
  15. (2.1) find(:all) with various options (p.40-42)
  16. (2.1.1) With limit, offset, select options (p.40)
  17. (2.1.2) With order parameter (p.40-41)
  18. (2.1.3) With conditions parameter (p.41-42)
  19. (2.2) find(:first) (p.42)
  20. (2.3) find() with id (p.42)
  21. (2.4) Dynamic attribute-based finders (p.42-43)
  22. (2.5) find_by_sql method (p.43)
  23. (2.6) find_or_create_by_ method (p.43-44)
  24. (2.7) find() with params (44) -- EMPTY/SKIPPED
  25. EXERCISE #3: Validation (p.44-75)
  26. (3.1) Delete all rows of the "users" table through migration (p.44-49)
  27. (3.2) Perform validation using validation helpers (p.50-60)
  28. (3.3) Add email field to the users table (p.61-69)
  29. (3.4) Add validation logic for the "email" field (p.70-71)
  30. (3.5) Perform validation testing on the email field (p.72-75)
  31. EXERCISE #4: Migrations (p.76-105)
  32. (4.1) Add a new column (p.76)
  33. (4.2) Rename a column - chane "email" to "email_addr" (p.76-83)
  34. (4.3) Roll back the change - change "email_addr" to "email" (p.84-89)
  35. (4.4) Display "schema.rb" file that maintains the current migration number (p.90-91)
  36. (4.5) Exercise with multiple veresions of migration files (p.92-105)
  37. EXERCISE #5: Statistics (p.106-107)
  38. EXERCISE #6: Callbacks (p.108--114)
  39. (6.1) Add callback to the Model (p.108-114)
  40. FINISHED EXERCISES (11:38am on 4/21/2009)
  41. Homework (p.115)
  42. HW-part 1: Migration: Add another column called "credit_card" to the users table as following as part of ActiveRecord_Creation project. (Or you can create a new project and new database. I will call the new project as MyActiveRecord here.) The type of credit_card field is string. (4/21/09: done, HINT ON PAGE 76) OUTPUT: (in C:/cygwin/home/jasnow/RAILSPASSION/ActiveRecord_Creation)
    == 20090421151649 RenameEmailField: migrating =================================
    -- rename_column(:users, :email, :email_addr)
    -> 0.2011s
    == 20090421151649 RenameEmailField: migrated (0.2018s) ========================
    == 20090421162301 AddCreditCxard: migrating ===================================
    -- add_column(:users, :credit_card, :string)
    -> 0.1927s
    == 20090421162301 AddCreditCxard: migrated (0.1933s) ==========================
  43. HW9-part 2: Validation: Add the following validation logic for the credit_card field.
    1. It has to be unique.
    2. User can enter the credit card format in the following format. The x has to be numeric value.
      1. xxxx-xxxx-xxxx-xxxx (format #1)
      2. xxxx xxxx xxxx xxxx (format #2)
      3. xxxxxxxxxxxxxxxx (format #3) NOTE: 16 digits
  44. HW9-part3: Callbacks: Use callbacks - before_save and before_create - to convert the format #1 and format #2 to format #3 meaning the actual table contains only format #3. (4/21/09: done, HINT ON PAGE 108) Loading development environment (Rails 2.1.0)
    RAILS CONSOLE: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    >> ?> user = User.new(:name => "OnlyDigits", :hobby => "tennis", :age => 49, :email_addr => "jasnow@hotmail.com", :credit_card => "1234567890123456" )
    => #
    >> user.save
    => true
    >> user = User.new(:name => "Digits N. Blanks", :hobby => "swimming", :age => 19, :email_addr => "dnbxxx@gmail.com", :credit_card => "1234 5678 9012 3456" )
    => #
    >> user.save
    => true
    >>
    User.create(:name => "Digits N. Dashes", :hobby => "swimming", :age => 19, :email_addr => "dndxxx@gmail.com", :credit_card => "1234-5678-9012-3456" )
    ?> => #
    >> User.create(:id => 20, :name => "Bad DashInColumn1", :hobby => "swimming", :age => 19, :email_addr => "bdc1xxx@gmail.com", :credit_card => "-1234567890123456" )
    => #
    >> user = User.new(:name => "Bad DashInColumn1", :hobby => "swimming", :age => 19, :email_addr => "bdc1xxx@gmail.com", :credit_card => "-1234567890123456" )
    => #
    >> user.save
    => false
    >>
    ?> user = User.new(:name => "BadDashInColumn1", :hobby => "swimming", :age => 19, :email_addr => "bdc1xxx@gmail.com", :credit_card => "-1234567890123456" )

    => #
    >> ?> user.save
    => false
    >> user = User.new(:name => "BadValue", :hobby => "swimming", :age => 19, :email_addr => "bdc1xxx@gmail.com", :credit_card => "BAD VALUE" )
    => #
    >> user.save
    => false
  45. HW9-part4: Submit: Send the following files to railshomeworks@sun.com with Subject as RailsHomework-rails_activerecord.
  • Zip file of the the MyActiveRecord NetBeans project. (Someone else should be able to open and run it as a NetBeans project.) You can use your favorite zip utility or you can use "jar" utility that comes with JDK as following.
    • cd MyActiveRecord directory> (assuming you named your project as MyActiveRecord)
    • jar cvf MyActiveRecord.zip MyActiveRecord (MyActiveRecord should contain nbproject directory)
  • Captured output screen - name it as RailsHomework-rails_activerecord.gif orRailsHomework-rails_activerecord.jpg (or RailsHomework-rails_activerecord.)
    • Any screen capture that shows that your program is working is good enough.
  • Emailed on 4/21/2009/DONE with your lesson.

Week 8: Rails Passion Course

  1. Week 8: Ruby/JRuby and Rails Support in NetBeans (Topics covered: Coding/Editing, Refactoring, Testing, Debugging, Profiling, Deployment)
  2. 5553_rails_netbeans.zip (Unzip it in a directory of your choice and read lab document from /rails_netbeans/index.html to proceed) (4/19/09: Downloaded)
  3. Week 8 Resources
    o Websites
    + NetBeans Ruby and Rails Learning Trail
    + NetBeans Ruby wiki
    o Database
    + Ruby Database Integration with NetBeans 6.1 from wiki.netbeans.org
    + Using MySQL Administrator Tool of NetBeans 6.1 Beta blog
    o Rails support in NetBeans blogs
    + Surprising Contender: NetBeans as a Ruby+MYSQL IDE blog by Timothy M. O'Brien (April 2008)
    + So long TextMate?... Hello NetBeans? Really? Yeah, really. blog (April 2008)
    + Tor Norbye's Weblogs
    + Why You Want NetBeans (for Rails development) blog by Eric Armstong (May, 2008)
    # See the end part of the blog.
  4. Presentation - PDF: 1 slide per page (OR) OpenOffice file (36 pages) (4/19/09: Read)
  5. Online Lab/ChangeLog document (This is the same document you will find in the hands-on lab zip file) (2 pages)
  6. EXERCISE 1 (60 minute screencast): In this exercise, you are going to watch and listen variious NetBeans screencasts from the NetBeans Ruby and Rails Learning Trail website and try them yourselves.
  7. (1.1) Using Code Completion (2:04 minutes)
  8. (1.2) Using Hints and Quick Fixes (3:21 minutes)
  9. (1.3) Using Live Code Templates (2:29 minutes) (http://ruby.netbeans.org/codetemplates-ruby.html)
  10. (1.4) Editing Ruby Code (4:55 minutes)
  11. (1.5) Debugging Ruby Code (4:38 minutes)
  12. EXERCISE 2 (30 minute screencast): In this exercise, you are going to exercise various Ruby editing features of NetBeans.
  13. (2.1) Ruby Editing features (4/19/09: Printed out and read this section - 14 pages)
  14. Homework (No Homework)

Thursday, April 16, 2009

Week 7: Rails Passion Course

  1. Week 7: Scaffolding (Scaffolding is a way to quickly put an Active Record class online by providing a series of standardized actions for listing, showing, creating, updating, and destroying objects of the class. These standardized actions come with both controller logic and default templates that through introspection already know which fields to display and which input types to use. // Topics covered: What is scaffolding?, Controller (that is generated through scaffolding), Templates (that are generated through scaffolding))
  2. 5523_rails_scaffold.zip (Unzip it in a directory of your choice and read lab document from /rails_scaffold/index.html to proceed) (4/16/09: Loaded)
  3. Week 7 Resources
    o Web services, Rails-style blog by Jamis (March, 2006)
    + Explains how respond_to works - respond_to will be covered in REST topic below
    o Rails 2.0 Scaffolding blog by David Lynch
  4. Week 7 Presentation - PDF: 1 slide per page (OR) OpenOffice file (15 pages) (4/16/09: Read)
  5. Week 7 Exercises -Online Lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (72 pages) (4/17/09: Read thru the powerpoints)
  6. #0: Start Db (done) (p.2)
  7. (1.1) Create new project: rubyweblog with WEBrick and JRuby 1.1.4. (p.3-4)
  8. (1.2) Create new database (p.4-5)
  9. (1.3) Generate scaffold (p.6-18)
  10. (1.4) Migrate the database (to Current Version) (p.19-21)
  11. (1.5) Add a URL routing and delete index.html from Public directory (p.22-25)
  12. (1.6) Build and run the application (p.26-27)
  13. (1.7) Study control flow - Displaying the 1st page (p.28-31)
  14. (1.8) Study control flow - Creating a new post (p.31-37)
  15. EXERCISE #2: Add another field to the model in rubyweblog application
  16. (2.1) Add another field to the model (through migration) (p.37-41)
  17. (2.2) Modify [view] templates (p.42-44)
  18. (2.3) Save changes and Refresh the browser (p.45-53)
  19. (2.4) Add a validation (p.54-59)
  20. (2.5) Change the look and feel (p.60-62)
  21. (2.6) Perform various find operations through Rails console (p.63-67)
  22. NOW FOR THE HOMEWORK
  23. Week 7 Homework (68 pages) (p.67-68)
  24. HW7: Step 1: Start DB. (p.2)
  25. HW7: Step 2: Create new project (myscaffoldingapp) with WEBrick and JRuby 1.1.4. (p.2-3)
  26. HW7: Step 3: Now create databases. (p.3-4)
  27. HW7: Step 4: Now create scaffold - Course model with 2 attributes (name:string and credit:integer) (p.6-10)
  28. HW7: Step 5: Now migrate the database. (p.11-21)
  29. HW7: Step 6: Fix Configuration (routes.rb == "courses", deleted index.html) (p.22-25)
  30. HW7: Step 7: Build/Ran (p.26-27) http://localhost:3000/courses/new (WORKED; Added 7 courses/credits)

Week 6: Rails Passion Course - On My New Mac

  1. Repeated Week 6 Homework (HW6) on my new White Mac Laptop.
  2. (AL#1) Creating new project: studentapp in /Users/whitemac/NetBeansProjects directory using "Built-in JRuby 1.1.4" and "Glassfish V3".
  3. Note the Mac experience is different from PC. Asked for Database Configurations/Accepted defaults/Continued.
  4. Then went to "Install Rails" and I selected "Update JRuby OpenSSL Support" and it worked. Then I selected "Update Rails" (from 2.1.0) to 2.3.2.
  5. Then I SKIPPED "Install Warbler" for now.
  6. Selected "Finished" and it failed and asked for run "sudo gem update --system" so I did. After the "gem update" finished, I selected "OK" and it finished creating the Rails Project.
  7. NOTE: Appears that MySQL is not installed on MAC, so going back to AL#0 to install MySQL on the MAC.
  8. THURSDAY (Next Day): Found another article (http://sheldonconaty.com/?p=7) and followed it to use this article: http://www.hennessynet.com/blog/?p=40 about setting up .bash_profile and macports and mySQL.
  9. Here is the log: $ sudo port install mysql5 +server (p.1)
    ---> Fetching zlib
    ---> Attempting to fetch zlib-1.2.3.tar.bz2 from http://www.zlib.net/
    ---> Verifying checksum(s) for zlib
    ---> Extracting zlib
    ---> Applying patches to zlib
    ---> Configuring zlib
    ---> Building zlib
    ---> Staging zlib into destroot
    ---> Installing zlib @1.2.3_2
    ---> Activating zlib @1.2.3_2
    ---> Cleaning zlib
    ---> Fetching openssl
    ---> Attempting to fetch openssl-0.9.8k.tar.gz from http://distfiles.macports.org/openssl
    ---> Verifying checksum(s) for openssl
    ---> Extracting openssl
    ---> Applying patches to openssl
    ---> Configuring openssl
    ---> Building openssl
    ---> Staging openssl into destroot
    ---> Installing openssl @0.9.8k_0
    ---> Activating openssl @0.9.8k_0
    ---> Cleaning openssl
    ---> Fetching ncursesw
    ---> Attempting to fetch ncurses-5.7.tar.gz from http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/ncurses
    ---> Verifying checksum(s) for ncursesw
    ---> Extracting ncursesw
    ---> Configuring ncursesw
    ---> Building ncursesw
    ---> Staging ncursesw into destroot
    ---> Installing ncursesw @5.7_0
    ---> Activating ncursesw @5.7_0
    ---> Cleaning ncursesw
    ---> Fetching ncurses
    ---> Verifying checksum(s) for ncurses
    ---> Extracting ncurses
    ---> Configuring ncurses
    ---> Building ncurses
    ---> Staging ncurses into destroot
    ---> Installing ncurses @5.7_0
    ---> Activating ncurses @5.7_0
    ---> Cleaning ncurses
    ---> Fetching readline
    ---> Attempting to fetch readline-6.0.tar.gz from http://distfiles.macports.org/readline
    ---> Verifying checksum(s) for readline
    ---> Extracting readline
    ---> Applying patches to readline
    ---> Configuring readline
    ---> Building readline
    ---> Staging readline into destroot
    ---> Installing readline @6.0.000_1
    ---> Activating readline @6.0.000_1
    ---> Cleaning readline
    ---> Fetching mysql5
    ---> Attempting to fetch mysql-5.0.77.tar.gz from http://mysql.orst.edu/Downloads/MySQL-5.0
    ---> Attempting to fetch mysql-5.0.77.tar.gz from http://mysql.mirrors.pair.com/Downloads/MySQL-5.0/
    ---> Verifying checksum(s) for mysql5
    ---> Extracting mysql5
    ---> Applying patches to mysql5
    ---> Configuring mysql5
    ---> Building mysql5
    ---> Staging mysql5 into destroot
    ---> Creating launchd control script
    ###########################################################
    # A startup item has been generated that will aid in
    # starting mysql5 with launchd. It is disabled
    # by default. Execute the following command to start it,
    # and to cause it to launch at startup:
    #
    # sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
    ###########################################################
    ---> Installing mysql5 @5.0.77_2+server
    ******************************************************
    * In order to setup the database, you might want to run
    * sudo -u mysql mysql_install_db5
    * if this is a new install
    ******************************************************
    ---> Activating mysql5 @5.0.77_2+server
    ---> Cleaning mysql5
    al-snows-macbook:~ whitemac$
    al-snows-macbook:~ whitemac$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
    Password:
  10. Then did this:
    $ sudo -u mysql mysql_install_db5
    Password:
    Installing MySQL system tables...
    090416 20:07:40 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
    090416 20:07:40 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
    090416 20:07:40 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
    OK
    Filling help tables...
    090416 20:07:40 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
    090416 20:07:40 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
    090416 20:07:40 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
    OK
    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system
    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:
    /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
    /opt/local/lib/mysql5/bin/mysqladmin -u root -h al-snows-macbook.local password 'new-password'


Friday, April 10, 2009

Week 6: Rails Passion Course

  1. Week 6: Rails Basics (Topics covered: What is and Why Ruby on Rails?, Building HelloWorld Rails application step by step, Key concepts of Rails application development - App directory structure (MVC), Environment, Rake, Generator, Migration, Rails console)
  2. Week 6 Resources
    o Web sites
    + Ruby and Rails Learning Trail website from netbeans.org
    # Pretty comprehensive set of Rails tutorials
    + Ruby on Rails API reference from api.rubyonrails.org
    o Ruby on Rails tutorials
    + Ruby on Rails 2.1.x Tutorial site
    # Pretty comprehensive set of Rails tutorials
    + railscasts.com
    + Creating a Ruby Weblog in 10 minutes tutorial from netbeans.org
    + Getting Started with JRuby on GlassFish Screencast from glassfish.dev.java.net
    + JRuby on Rails for the enterprise (with performance) article
    + What is Ruby on Rails tutorial from onlamp.com
    + Sample Catalog Application using JRuby and Rails tutorial (Oct. 2007) by Carol McDonald
    o MySQL
    + Connecting to a MySQL Database tutorial from netbeans.org
    o Articles
    + NetBeans Ruby Pack article from netbeans.org
    o Presentations
    + Rails Presentations from ruby-doc.org
    + Ruby on Rails presentation presentation by Miguel Vega and Ezwan Faiz
    + Pursuing beauty with Ruby on Rails presentation by David Heinemeier Hansson
    + Top 13 Ruby on Rails Presentations website
    + "Why Ruby On Rails" Video presentation (March, 2007) by gregg
    + Rails Controllers and Routing presentation by Obie Fernandez (RubyEast 2007)
  3. 5521_rails_basics.zip (Unzip it in a directory of your choice and read lab document from /rails_basics/index.html to proceed) (4/10/2009: Installed/done)
  4. * Presentation (PDF: 1 slide per page (OR) OpenOffice file) (53 pages) (4/10/2009: Read twice)
  5. Online Lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (135 pages)
  6. Exercise 0: Start MySQL database server (p.2-11) Found this tutorial: http://www.netbeans.org/kb/docs/ide/mysql.html
  7. (0.1) step 1: Did this instead. Inside netbeans/services tab/databases/right click/register mysql server. On page 5 I filled out Admin Properties with the admin tool at c:/Deep*/Ins*2.0*/mysql/bin/mysqladmin.exe, etc. I left admin password empty as told on page 3.
  8. (0.1) step 2: Test if the MySql database is running (pg. 7). Output: Uptime: 341 Threads: 2 Questions: 689 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 2.021
  9. Exercise 1: Build and run "helloworld" Rails application (pg. 11-85)
  10. (1.1) Create Ruby on Rails NetBeans project (p.11-19) Note that I used "helloworld", RAILSPASSION directory, Built-in JRuby (1.1.4), and Glassfish to create the "New Ruby on Rails Application" project. Output was: http://www.pastie.org/443997 Looked OK.On page 14, appears that example has more files that my project. Unclear if OKAY or NOT. Appear OK for now.
  11. (1.2) Create Database (p.19-35) Since I am using Netbeans 6.5, I needed to skip pages 19-23). Now on page 24 and 25 I followed the directions (helloworld/"Run/Debug Rake Task"/db:create/Run). Did not get any feedback so repeated it with debug on and got this: Fast Debugger (ruby-debug-ide 0.3.1) listens on localhost:63550
    (in C:/cygwin/home/jasnow/RAILSPASSION/helloworld)
    helloworld_development already exists
  12. (1.2) step 2: page 27: To verify existance of helloworld_development, I had to use Refresh.
  13. (1.3) Create Model. (page 35-45) On page 38, I ran Rails Generator for Model and got this: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    exists app/models/
    exists test/unit/
    exists test/fixtures/
    create app/models/message.rb
    create test/unit/message_test.rb
    create test/fixtures/messages.yml
    create db/migrate
    create db/migrate/20090412003007_create_messages.rb
  14. (1.4) Create database table through migration (p.45-55) Followed directions on page 48 to migrate to Current Version and got this: (in C:/cygwin/home/jasnow/RAILSPASSION/helloworld)
    == 20090412003007 CreateMessages: migrating ===================================
    -- create_table(:messages)
    -> 0.0727s
    == 20090412003007 CreateMessages: migrated (0.0732s) ==========================
  15. (1.5) Create a Controller (p.55-62)
  16. (1.5) step 1 (pg.56) Used Rails Generator to generate Controller and got this: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    exists app/controllers/
    exists app/helpers/
    create app/views/hello
    exists test/functional/
    create app/controllers/hello_controller.rb
    create test/functional/hello_controller_test.rb
    create app/helpers/hello_helper.rb
  17. (1.6) Write a View (p.62-67) Created a RHTML file and added some text.
  18. (1.7) Set URL routing (p.67-73) Changed "welcome" to "hello" on line 34 of Configuration/routes.rb file. Then deleted index.html under Public directory.
  19. (1.8) Build and run the application (helloworld). (pg.73-??) Tried to run it and got this: Warning: Cannot open log file: C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1/logs/jvm.log
    Warning: Forcing option -XX:LogFile=C:\Users\jasnow\AppData\Local\Temp\\hs_pid7316.log
    INFO: Launching GlassFish on Apache Felix OSGi platform
    Welcome to Felix.
    =================
    ERROR: org.apache.felix.framework.cache.BundleCache: Unable to create directory: C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\.felix\gf
    INFO: Cannot create record of lastModified file
    Error creating bundle cache:
    java.lang.RuntimeException: Unable to create profile directory.
    at org.apache.felix.framework.cache.BundleCache.initialize(BundleCache.java:353)
    at org.apache.felix.framework.cache.BundleCache.(BundleCache.java:95)
    at org.apache.felix.framework.Felix.(Felix.java:248)
    at org.apache.felix.framework.Felix.(Felix.java:125)
    at org.apache.felix.main.Main.main(Main.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.glassfish.bootstrap.ASMainFelix$1.run(ASMainFelix.java:101)
    at java.lang.Thread.run(Thread.java:619)
  20. So I change "helloworld/Set Configuration/Customize/WEBrick and reran it and got this: => Booting WEBrick...
    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    [2009-04-11 21:04:18] INFO WEBrick 1.3.1
    [2009-04-11 21:04:18] INFO ruby 1.8.6 (2008-08-28) [java]
    [2009-04-11 21:04:18] INFO WEBrick::HTTPServer#start: pid=332711452 port=8080
    => Rails 2.1.0 application started on http://0.0.0.0:8080
    => Ctrl-C to shutdown server; call with --help for options
    127.0.0.1 - - [11/Apr/2009:21:04:22 EDT] "GET / HTTP/1.1" 404 570
    - -> /
    127.0.0.1 - - [11/Apr/2009:21:04:23 EDT] "GET /favicon.ico HTTP/1.1" 200 0
    - -> /favicon.ico
    Also got this in the web browser as seen on page 75:
    Unknown action No action responded to index
  21. So I changed the URL to "http://localhost:8080/hello/say_hello" and got this as seen on page 76: My greeting message is Hello World!
    The current time is Sat Apr 11 21:09:17 -0400 2009

  22. Modified hello_controller.rb and typed URL: http://localhost:8080/ and it worked as seen on page 79.

  23. Note that the bottom of page 79 to page 85 are Troubleshooting Solutions.
  24. Exercise #2: Add another field to a Model (p.85-??)
  25. (2.1) Add another field to a table through migration (p.86-93) On page 87 and 88, Generate migration and got this: JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    exists db/migrate
    create db/migrate/20090412012221_add_name.rb
  26. (2.1) Ran "Migrate Database" and got this: (in C:/cygwin/home/jasnow/RAILSPASSION/helloworld)
    == 20090412012221 AddName: migrating ==========================================
    -- add_column(:messages, :name, :string)
    -> 0.1114s
    == 20090412012221 AddName: migrated (0.1121s) =================================
  27. (2.2) Modify the controller (p.94-95) Added a line to Controllers/hello_controller.rb.
  28. (2.3) Modify the view. (pg. 96-97) (SO step 2.2 stuff can be seen in the browser)
  29. (2.4) Save the changes and Refresh the browser (p.98-100) IT WORKED.
  30. (2.5) Display log file (p.101-102) Opened up Logs/development.log. WORKED.
  31. (2.6) Modify the view (p.103-106) Added code and refreshed browser. IT WORKED.
  32. Exercise #3: Add another template to the application (p.106-??)
  33. (3.1) Create a new template (p.106-109) Created say_goodbye.html.erb.
  34. (3.2) Modify existing template (p.110-112) Changed say_hello.rhtml.
  35. (3.3) Add a new section (p.113-116) Add a new section to hello_controller.rb.
  36. (3.4) Save all changes and refresh the browser (p.115-118) IT WORKED.
  37. Exercise #4: Build and run "helloname" application (p.121-??)
  38. (4.1) Create Ruby on Rails NetBeans project (p.121-122) DONE
  39. (4.2) Create database (p.122) DONE
  40. (4.3) Create model (p.122-123) DONE
  41. (4.4) Migrate the database (p.123) DONE
  42. (4.5) Create a Controller (p.124-125) DONE
  43. (4.6) Write templates (p.125-127) DONE
  44. (4.7) Set the URL routing and delete index.html (p.127-129) DONE
  45. (4.8) Build and run the application (p.129-131) NOTE that pages 132-134 are TROUBLESHOOTING pages.
  46. Finished 10:19pm. Started at 6:55pm. => 3.5 hours or 210 minutes
  47. Homework Exercise (p.134-135)
  48. (AL#1) Created project: studentapp, with Jruby and WEBrick. (WORKED)
  49. (AL#2) Created 3 databases. (done/verified under Services)
  50. (AL#3) Connected to step 49's development database. (done)
  51. (AL#4) Create Student model with 2 attributes: name:string and age:integer.
  52. (AL#5) Migrated database to Current version. (done)
  53. (AL#6) Create Ask controller. (done)
  54. Finished it.


Week 5: Rails Passion Course

  1. Week 5: JRuby Basics (Topics to be covered: What is and what is not JRuby?, Why JRuby (over Ruby) & JRuby on Rails (Ruby on Rails)?, Why use (J)Ruby with Java? Calling Java from JRuby, Calling (J)Ruby from Java)
  2. o 5520_ruby_jruby.zip (Unzip it in a directory of your choice and read lab document from /ruby_jruby/index.html to proceed) (4/10/09: Installed/done)
  3. * Resources
    o Websites
    + JRuby wiki from wiki.jruby.org
    o Tutorials
    + Why You Want JRuby blog by Eric Armstrong (May 2008)
    + JRuby Tutorial by Charles Nutter and Ola Bini
    + JRuby wiki from en.wikipedia.org
    + Calling Java from JRuby wiki from wiki.jruby.org
    + Mixing Java and Ruby Development screencast
    + JRuby - Enterprise 2.0 presentation by James Crisp and Josh Price
    + Ola Bini Discusses JRuby from infoq.com
    + Charles Nutter discusses JRuby from infoq.com
    o NetBeans support of JRuby
    + JRuby Support in NetBeans IDE 6 Ask the Experts Transcript (May 2008)
    o GUI
    + Swing with JRuby: Developing a Desktop Application with the JRuby and Java Swing APIs tutorial by Teera Kanokkanjanarat
    + Swing with JRuby Part II: Packaging JRuby Desktop Application tutorial by Teera Kanokkanjanarat
    + Cheri project home site from cheri.rubyforge.org
    o Presentations
    + JRuby - Bringing Ruby to the JVM presentation by Charles Nutter and Thomas Enebo (Sep. 2006)
    + JRuby Presentation @ Vancouver Ruby User group event by Teera Kanokkanjanarat
    + Ola Bini's presentation
  4. Presentation (o PDF: 1 slide per page (OR) o OpenOffice file) (20 pages) (4/10/09: Read)
  5. Online Lab/Homework/Change Log document (This is the same document you will find in the hands-on lab zip file) (44 pages)
  6. Exercise 1: Build JRuby applications using Java classes
  7. (1.1) JRuby_ImportClass (p.2-3) Answer: ----Import a Java class, java.lang.System
    ----Display Java version using java.lang.System Java class
    Java verion used is 1.6.0_13-b03
  8. (1.2) JRuby_UseJavaJFrameClass (p.3) Answer: Got a small window with "Hello World!" in it.
  9. (1.3) JRuby_UseJavaJFrameClass2 (p.3-4) Answer: Got a "medium" red window with nothing but color in it.
  10. (1.4) JRuby_UseJavaTreeSetClass" (p.4-5) Answer: ----Create an object from TreeSet Java class
    ----Add entries to the TreeSet
    ----Display TreeSet
    value: Bar
    value: baz
    value: foo
  11. (1.5) JRuby_UseJavaArrayListClass (p.5-6) Answer: ----Create an object from ArrayList Java class
    ----Add entries to the ArrayList
    ----Add an entry using an index
    ----Display ArrayList
    value: foo
    value: Bar
    value: Sang Shin
    value: baz
    ----Display an entry using an index
    Sang Shin
  12. Exercise #2: Create Ruby Module from Java Packages (p.6-7)
  13. (2.1) JRuby_CreateModuleFromJavaPackage (p.6-7) Answer: ----Create a module from Java package
    ----Create a string
    This is my string from java.lang package
  14. (2.2) JRuby_CreateModuleFromJavaPackage2 (p.7) Answer: ----Create a Ruby Module from Java package
    ----Get Java version information
    1.6.0_13-b03
  15. Exercise #3: Use "FreeTTS" Speech Synthesizer 3rd-party Java Library (p.7-14)
  16. (3.1) JRuby_UseJavaSpeechLibrary (p.8-14) Changed properties to include the speech jar files. Ran the program and hear the two sentence and this: ----Allocate a voice
    ----Speak out
  17. Exercise #4: Use "JFreeChart" 3rd-party Java Library (p.14-21)
  18. (4.1) JRuby_UseFreeChartLibrary (p.14-21) Answer: Ran the program and saw the graph with this text: redefining File
    Rendering sparkline
  19. Exercise #5: Use your own Java library (p.22-31)
  20. (5.1) HelloJavaLibrary (p.22-31) Answer: init:
    deps-jar:
    Created dir: C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\HelloJavaLibrary2\build\classes
    Compiling 1 source file to C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\HelloJavaLibrary2\build\classes
    compile:
    Created dir: C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\HelloJavaLibrary2\dist
    Building jar: C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\HelloJavaLibrary2\dist\HelloJavaLibrary2.jar
    jar:
    BUILD SUCCESSFUL (total time: 0 seconds)
  21. (5.2) Create, build, and run JRuby application (p.31-42): Ran program and got this: ----Create an object from Hello Java class
    ----Invoke a method of from Hello object
    HelloMessage from Hello Java Class!!
  22. Exercise #6: Naming Conventions: (p.43-44)
  23. (6.1) JRubyNaming_JavaClass (p.43) Answer: Got small window with "Hello World!" in it.
  24. (6.2) JRubyName_JavaMethod (p.43-44) Answer: ----Create an object from Hello Java class
    ----Invoke a method of from Hello object
    HelloMessage from Hello Java Class!!
  25. Homework Exercise: First create a Java Library (p22-31) : init:
    deps-clean:
    clean:
    init:
    deps-jar:
    Created dir: C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\ComputeJavaLibrary\build\classes
    Compiling 1 source file to C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\ComputeJavaLibrary\build\classes
    compile:
    Created dir: C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\ComputeJavaLibrary\dist
    Building jar: C:\cygwin\home\jasnow\RAILSPASSION\ruby_jruby\samples\ComputeJavaLibrary\dist\ComputeJavaLibrary.jar
    jar:
    BUILD SUCCESSFUL (total time: 0 seconds)
  26. Then create JRuby application. IT WORKED. 7
    3
    0
    75












Thursday, April 9, 2009

Week 4: Rails Passion Course

  1. Week 4: Ruby Object Oriented Programming Concept
  2. * Resources
    o Self tutorial from rubylearning.com
    o Singleton class blog by Ola Bini (Sep. 2006)
  3. 5513_ruby_object.zip (Unzip it in a directory of your choice and read lab document from /ruby_object/index.html to proceed) (4/9/09: done)
  4. o Change Log
  5. * Presentation (o PDF: 1 slide per page (OR) o OpenOffice file) -- NO LINK.
  6. Exercises (p.1-
  7. Exercise #1: The concept of "self" (p.2-5)
  8. (1.1) RubyObject_self_in_TopLevelContext (p.2-3) : Answer: main
    Object
    main
  9. (1.2) RubyObject_self_instanceMethod (p.3): Answer: #
  10. (1.3) RubyObject_self_ClassMethod (p.3-4): Answer: MyClass
  11. (1.4) RubyObject_self_SingletonMethod (p.4): Answer: #
    #
  12. (1.5) RubyObject_self_SingletonMethod2 (p.4-5) Answer: #
    # (same number)
  13. Exercise #2: Singleton Method (p.5-
  14. (2.1) RubyObject_SingletonMethod (p.5-6) Had to type it in. Answer: #LT Object:0x4c272961>
    #LT
  15. (2.2) RubyObject_SingletonMethod2 (p.6) Had to type it in. Answer: #LT:0x30c06258>
    #LT:0x30c06258>'

    NOTE: BLOG IS EATING MY LESS THAN VALUES.

Week 3: Rails Passion Course

  1. Week 3: Ruby Meta Programming (Topic covered: What is and why meta-programming?, Ruby language characteristics (that make it a great meta-programming language, Introspection, Object#send, Dynamic typing (and Duck Typing), missing_method, define_method.)
  2. * Week 3 Resources
    o Meta programming
    + Meta Programming - Extending Ruby for Fun and Profit presentation by Dave Thomas (Dec. 2007)
    + Screencasting on Ruby Meta programming by Dave Thomas (June, 2008)
    + Metaprogramming Ruby by Glenn Vanderburg
    + Metaprogramming from Wikipedia
    + Ola Bini's blogs on Meta programming
    o Duck typing
    + Duck typing from wikipedia.org
  3. Lab/Homework: ZIP File: o 5511_ruby_meta.zip (Unzip it in a directory of your choice and read lab document from /ruby_meta/index.html to proceed) (4/9/2009: done)
  4. * Presentation o PDF: 1 slide per page (OR) o OpenOffice file (4/9/2009: done)
  5. * Lab and homework (o Change Log) (p.1-29)
  6. Exercise 1? Introspection (p.2-11)
  7. (1.1) RubyMeta_Introspection_respond_to: Answer: http://pastie.org/442378 (p.2-8)
  8. (1.2) RubyMeta_Introspection_respond_to2: Answer: (p.8-9) ----Define Hello class
    ----Check if Hello object has a method called myhellomethod
    true
    ----Check if Hello object has a method called xyz
    false
  9. (1.3) RubyMeta_Introspection_instance_of: Answer: ----Exercise instance_of? and kind_of? methods among object instances
    true
    false (should be "B", not "A")
    true
    ----Exercise instance_of? and kind_of? methods for a class
    true
    true
    ----Display class information
    A
    Class
  10. (1.4) RubyMeta_Introspection_methods: Answer: http://pastie.org/442385 (p.10-11) Surprised by the lst 3 sections (no output).
  11. Exercise 2 (p.11-15)
  12. (2.1) RubyMeta_Object_send_hello: Answer: (p.12) Hello gentle readers
    Hello gentle readers
    Hello gentle readers
    Hello gentle readers
  13. (2.2) RubyMeta_Object_send_plus: Answer: (p.12-13) 5
    5
    5
    5
    6
    6
    6
    6
  14. (2.3) RubyMeta_Object_send_hello2: Answer: (p.13-14) Hello Boston!
    Hello Boston!
    Hello Boston!
    Hello Boston!
  15. (2.4) RubyMeta_Object_send_hello3: (p.14-15): Answer: http://pastie.org/442403
  16. Exercise 3: Dynamic Typing (Duck Typing) (p.15-16)
  17. (3.0) Article: The Perils of Duck Typing: http://beust.com/weblog/archives/000269.html
  18. (3.1) RubyMeta_DynamicTyping (p.15-16): Answer: ----Call quack method for each item of the birds array. Only Duck and Mallard should be quacking.
    Duck is quacking!
    Mallard is quacking!
  19. Exercise 4: Missing Methods (p.16-23)
  20. (4.1) RubyMeta_MethodMissing_Error (p.15-18) Answer: ----Call a method that does not exist in the Dummy class and expect NoMethodError exception.
    C:\cygwin\home\jasnow\RAILSPASSION\ruby_meta\samples\RubyMeta_MethodMissing_Error\lib\main.rb:13: undefined method `a_method_that_does_not_exist' for # (NoMethodError)
  21. (4.2) RubyMeta_MethodMissing_Called (p.18-19) Answer: http://pastie.org/442416
  22. (4.3) RubyMeta_MethodMissing_Finder (p.19-20) Answer: ----Call a method that does not exist in the Finder class and observe that the method_missing is called.
    find(Something) is called
    find(by_last_name) is called
    find(by_title) is called
  23. (4.4) RubyMeta_MethodMissing_RomanToInteger (p.20-21) Answer: ----Convert Roman to Integer using method_missing
    4
    23
    2000
  24. (4.5) RubyMeta_MethodMissing_ProxyPattern (p.21-23) Answer: http://pastie.org/442423
  25. Exercise 5: Define Method (p.23-
  26. (5.1) RubyMeta_DefineMethod (p.23) Answer: ----Call a method that is defined via define_method
    Sang Shin loves Young Shin
  27. (5.2) RubyMeta_DefineMethod2 (p.23-28) Answer: ----Get a method name from a user. Type something in the Output window and press Enter.
    abcd (I typed this)
    ----Define Love class which has define_method
    ----Create an instance of Love class
    ----Invoke a method that was dynamically defined
    abcd
    method is being invoked
    Daniel loves Yina

  28. (5.3) RubyMeta_DefineMethod3 (p.28-29) Answer: ----a.barney is equivalent to a.fred
    In Fred
    ----a.wilma is equivalent to a.wilma
    Charge it!
    ----a.create_method(:betty) { p self }
    ----a.betty
    #
  29. Online lab/Homework document (This is the same document you will find in the hands-on lab zip file)

Tuesday, April 7, 2009

Week 2: Rails Passion Course

  1. Week 2's Theme is Ruby Blocks and Closures (Topics covered: What is block?, How to create a block?, How does a block get passed and executed?, Proc object, & operator, lambda, Where do blocks get used?, What is a closure.) and here are the references from the web site:
  2. Here is the PDF file: Presentation (4/7/2009: Read/Printed out ~half pages)
    1. PDF: 1 slide per page (33 pages)
    2. OpenOffice file
  3. Exercise #1: Ruby Blocks (p.1-9)
  4. (1.1) RubyBlock_TwoFormats (p.2-4)
  5. (1.2) RubyBlock_yieldExecuteSuppliedBlock (p.4-7)
  6. (1.3) RubyBlock_yieldWithParameters (p.7-8)
  7. (1.4) RubyBlock_yieldWithParameters2 (p.8-9)
  8. Exercise #2: Proc object and lambda (p.9-15)
  9. (2.1) RubyBlock_Proc_CreateAndCall (p.9-10)
  10. (2.2) RubyBlock_Proc_CreateAndCall2 (p.10-11) - Had to type it in, but easy.
  11. (2.3) RubyBlock_Proc_AsReturnValue (p.11)
  12. (2.4) RubyBlock_Proc_AsArgument (p.11-12)
  13. (2.5) RubyBlock_lambda (p.12)
  14. (2.6) RubyBlock_lambda_diffFromProcNew1 (p.13-14) - Got Different Output (think ok).
  15. (2.7) RubyBlock_lambda_diffFromProcNew2 (p.15)
  16. Exercise 3: Ruby & (Ampersand) Operator (p.15-17)
  17. (3.1) RubyBlock_Ampersand_blockToProc (p.16)
  18. (3.2) RubyBlock_Ampersand_ProcToBlock (p.17)
  19. Exercise #4: Blocks and Iterators (p.17-19)
  20. (4.1) RubyBlock_Iterator (p.18)
  21. (4.2) RubyBlock_Iterator2 (p.18-19)
  22. Exercise #5: Closure Basics (p.19-
  23. (5.0) RubyClosure_example0 (p.20-21)
  24. (5.1) RubyClosure_example1 (p.21)
  25. (5.2) RubyClosure_example2 (p.21-22) -- Tricky ;>)
  26. (5.3) RubyClosure_example3 (p.22-23)
  27. (5.4) RubyClosure_example4 (p.23-24) -- Finished at 4:30pm.
  28. Lab and homework
    1. 5512_ruby_blocks.zip (Unzip it in a directory of your choice and read lab document from /ruby_blocks/index.html to proceed)
    2. Online lab document (This is the same document you will find in the hands-on lab zip file)
    3. Homework
    4. Change Log

Sunday, April 5, 2009

Week 1: Rails Passion Course - 1.1 (Lab/Homework)

  1. Sunday - 3:19pm - Can't get Mac set up enough so I will do Week 1 on my Vista/64 box.
  2. Okay, now for the Lab/(1b3)Homework (87 pages). http://www.javapassion.com/rubyonrails/
  3. (1b2) Online lab document and (1b4) Change Log (overall)
  4. Downloaded (1b1) 5510_ruby_basics.zip and installed it in $HOME/RAILSPASSION as $HOME/RAILSPASSION/ruby_basics.
  5. I have Java SDK (JDK 6.0) (6 Update 13). (p.1)
  6. Uploaded NetBeans IDE 6.5.1. (p.1) http://www.netbeans.org/community/releases/65/1/install.html I pick the EVERYTHING option regarding languages. (p.1)
  7. Exercise 0: Install JDK and NetBeans IDE (20 minutes) (first 10 pages; Skipped this because already installed stuff)
  8. Exercise 1: Ruby Language Basics (30 minutes) (Pages 11-25)
  9. (1.2) IRB: (pages 26-29) NOTE: Could not find "Ruby Shell (IRB)" so I checked past emails from group and found that I now just RIGHT click on top Ruby program "MyRubyProgramWk1" and select "Ruby Shell (IRB)". (p.26)
  10. (1.3) StringClass: (pages 29- 38) NOTE: On page 30, I had to point Netbeans to my $HOME/RAILSPASSIONS/ruby_basics/samples directory.
  11. (1.4) EverythingsIsObject (pages 38-41)
  12. (1.5) Ruby_ArrayClass (pages 41-42)
  13. (1.6) Ruby_Iteration (pages 43-44)
  14. (1.7) Ruby_HashClass (pages 44-45)
  15. (1.8) Ruby_HashClass_Iteration (pages 45-46)
  16. (1.9) Ruby_NamingConvention (pages 46-47)
  17. (1.10) Ruby_SymbolClass (pages 47-48)
  18. (1.11) Ruby_SymbolClass2 (pages 48-49)
  19. (1.12) Ruby_RegularExpression (page 49)
  20. (1.13) Ruby_StringClass2 (page 50)
  21. (1.14) Ruby_StringClass_Interpolation (pages 50-51)
  22. (1.15) Ruby_Numbers (pages 51-51)
  23. Exercise 2: Ruby Class and Objects (30 minutes) (p.52-56)
  24. (2.1) RubyClass_HelloClass (pages 52-53)
  25. (2.2) RubyClass_attr_accessor (pages 53-54)
  26. (2.3) RubyClass_inheritance" (pages 54-56)
  27. (2.4) RubyClass_AddMethod" (pages 56-56)
  28. Exercise 3: Ruby Methods (30 minutes) (pages 57-63)
  29. (3.1) RubyMethod_Chaining (page 57)
  30. (3.2) RubyMethod_ClassMethod (page 58)
  31. (3.3) RubyMethod_DefaultValueArgument (pages 58-59)
  32. (3.4) RubyMethod_VariableArguments (page 59)
  33. (3.5) RubyMethod_ArrayToArguments (pages 59-60)
  34. (3.6) RubyMethod_HashArgument (page 60)
  35. (3.7) RubyMethod_Parentheses (page 61)
  36. (3.8) RubyMethod_Bang (page 62)
  37. (3.9) RubyMethod_Bang2 (page 62-63)
  38. (3.10) RubyMethod_Alias (page 63)
  39. Exercise 4: Ruby Variables (10 minutes) (pages 64-66)
  40. (4.1) RubyVariable_dynamicTyping (page 64)
  41. (4.2) RubyVariable_LocalVariable (page 64-65)
  42. (4.3) RubyVariable_ClassVariable (page 65-66)
  43. Exercise 5: Ruby Modules (30 minutes) (pages 66-69)
  44. (5.1) RubyModule_Namespace (pages 66-67)
  45. (5.2) RubyModule_Mizin1 (pages 67-68)
  46. (5.3) RubyModule_Mixin2 (pages 68-69)
  47. Exercise 6: Ruby IO (30 minutes) (pages 69-78)
  48. (6.1) RubyIO_keyboard (pages 69-73)
  49. (6.2) RubyIO_file (pages 78)
  50. Exercise 7: Ruby Control Structure (30 minutes) (pages 78-82)
  51. (7.1) RubyControl_Assignment (pages 78-78)
  52. (7.2) RubyControl_TrueFalse (page 79)
  53. (7.3) RubyControl_Conditionals (page 80)
  54. (7.4) RubyControl_Loops (page 80-82)
  55. Exercise 8: Exception (30 minutes) (pages 82-
  56. (8.1) RubyException_raise (page 82-84)
  57. (8.2) RubyException_rescue (page 85)
  58. (8.3) RubyException_retry (page 85-86)
  59. (8.4) RubyException_structure (page 86)
  60. Homework Exercise (for people who are taking Sang Shin's "Ruby/Jruby/Rails Development online course")
  61. Homework done and emailed at ~7:30pm on 4/5/2009. Hardest part was figuring out how to create ZIP archive.
  62. Two misc typos: (a) Page 51: "Ruby_StringClass_Numbers" should be "Ruby_Numbers".
    (b) Page 78: "Ruby_Assignment" should "Ruby_Assigments" to match the code.

Friday, April 3, 2009

Week 1: Rails Passion Course - 1.1

  1. My very first blog for the Rails Passion Course. Here is the TOC (found in notebook bineder under TOC section): http://www.javapassion.com/rubyonrails/
  2. Already registered on Google Group. Also created this blog.
  3. Read the FAQ (0). Due Date is 2 weeks after end of course.
  4. Starting to (1) do Week One Lessons under step 1 ("Ruby Basics").
  5. Watching (1a1) PDF 1 ("Basic Ruby"). "irb --simple-prompt" (slide 13) (ALL 99 slides; printed out about half of the slides)
  6. (1a2) OpenOffice file - Unclear what to do with this. Assume duplicate of "PDF_1"
  7. Pre-Lab/Homework Feedback:
    1. The main TOC and the following contents are not in the same order. Some
    things are missing.
    2. Where do you talk about Number and Array on slide 23 of PDF_1.
    3. Slide 76 - 2nd bullet ends with "and" - unclear if we are missing something.
  8. Skipped over the Lab/Homework to reference section. Went to end [(1c5) Forums] and subscribed to Nabble. Remember to check them for Netbeans questions and answers.
    1. Postings
    2. Subscription/Unsubscription
  9. Going backward: (1c4) Regular Expression - two references (wikipedia and ruby-doc.org)
    1. Posix Basic Regular Expression from wikipedia.com
    2. Ruby regular expression tutorial from www.ruby-doc.org
  10. Continuing backward:(1c3) Presentations (2 of them)
    1. Ruby Presentations from ruby-doc.org
      1. Ruby course by Brian Schröeder's immersive Ruby programming course
      2. 10 Things Every Java Programmer Should know About Ruby by Jim Weirich
    2. Get to the point presentation by Ryan Platte and John Long
  11. Continuing backward: (1c2) Ruby Websites (3 of them)
    1. Ruby Development Center from developers.sun.com/ruby/
    2. Ruby-doc.org
      1. This is where you find tons of info. on Ruby.
    3. Ruby from ruby-lang.org
  12. Continuing backward: (1c1) Basic Ruby Tutorials (7 of them)
  13. I will do the Lab/Homework in a separate blog post.