Wednesday, June 3, 2009

Week 21 "Optional 6": Rails Passion Course

  1. Rails Example Application - TimeTracker Application (Week 21/Option 6)
  2. Presentation:PDF: 1 slide per page (OR)OpenOffice file: None
  3. Homework: None
  4. Resources
    o Ruby Time Tracker homesite from code.google.com/rubytime
  5. 5547_rails_timetracker_app.zip (Unzip it in a directory of your choice and read lab document from /rails_timetracker_app/index.html to proceed) (6/3/2009: Downloaded)
o Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file)

Week 21 "Optional 5": Rails Passion Course

  1. Rails Example Application - FreeMIS Application (Week 21/Optional 5)
  2. Presentation:PDF: 1 slide per page (OR) OpenOffice file: None
  3. Resources
    o FreeMIS homesite from www.freemis.net
  4. Homework: None
  5. 5546_rails_freemis_app.zip (Unzip it in a directory of your choice and read lab document from /rails_freemis_app/index.html to proceed) (6/3/09: Downloaded)
  6. Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (6/3/2009: Had problems so deferred)

Week 21 "Optional 4": Rails Passion Course

  1. Rails Example Application - Substruct Application (ECommerce Application) (Week 21/Optional 4)
  2. Presentation - there is no presentation.
  3. Resources
    o Substruct homesite
    o Installing Substruct blog
  4. Homework: 6/3/2009: Checked/None Yet.
  5. 5542_rails_substruct_app.zip (Unzip it in a directory of your choice and read lab document from /rails_substruct_app/index.html to proceed) (6/3/2009: Downloaded)
  6. Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (6/3/2009: Started)
  7. Had problems so deferred.

Week 21 "Optional 3": Rails Passion Course

  1. Rails Example Application - Typo Application (Week 21/Optional 3)
  2. Presentation - there is no presentation
  3. Homework - tbd (None yet)
  4. Resources
    o typo homesite from www.typosphere.org
  5. 5543_rails_typo_app.zip (Unzip it in a directory of your choice and read lab document from /rails_typo_app/index.html to proceed) (6/3/09: Downloaded)
o Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file)

Week 21 "Optionals/Empties": Rails Passion Course

  1. Ruby Gems (Week 21/Optional 1)
  2. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  3. Download: None
  4. Lab/Change Log: None
  5. Resources
    o RubyGems Manual from rubygems.org
  6. Rails Security (Week 21/Optional 2)
  7. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  8. Download: None
  9. Lab/Change Log: None
  10. Resources
    o Ruby on Rails Security Guide document from www.quarkruby.com
  11. Caching (Week 21/Optional 7)
  12. Link goes back to TOC, so done.
  13. Performance (Week 21/Optional 8)
  14. Download: None
  15. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  16. Lab/Change Log: None
  17. Resources: None
  18. Action Mailer (Week 21/Optional 9)
  19. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  20. Download: None
  21. Lab/Change Log: None
  22. Resources: Action Mailer from api.rubyonrails.org
  23. Rails and Other Web Technologies (Week 21/Optional 10)
  24. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  25. Download: None
  26. Lab/Change Log: None
  27. Resources: jMaki on Rails blog by Arun Gupta (March, 2008)
  28. Plug-in (Week 21/Optional 11)
  29. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  30. Download: None
  31. Lab/Change Log: None
  32. Resources: None
  33. Misc Topics (Week 21/Optional 12)
  34. Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
  35. Download: None
  36. Lab/Change Log: None
  37. Resources

Week 20: Rails Passion Course

  1. Rails Example Application - Redmine Application (Week 20)
  2. Presentation - there is no presentation
  3. 5539_rails_redmine_app.zip (Unzip it in a directory of your choice and read lab document from /rails_redmine_app/index.html to proceed) (6/3/2009: Downloaded)
  4. Homework: "TBD" (Nothing Yet)
  5. Resources
    o Redmine homesite
    o Redmine sample application from www.redmine.org
  6. Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (6/3/09: Successfully finished the Lab, therefore finished with HW20)

Tuesday, June 2, 2009

Week 19: Rails Passion Course

  1. Rails Example Application - Flickr Application (Week 19)
  2. Presentation - there is no presentation.
  3. Resources - there is no resources.
  4. Homework - There is no Homework this week/unit.
  5. 5541_rails_flickr_app.zip (Unzip it in a directory of your choice and read lab document from /rails_flickr_app/index.html to proceed) (6/2/09: Downloaded)
  6. Online lab document/ Change Log (This is the same document you will find in the hands-on lab zip file) (6/6/2009: Started over)
  7. (1.1) Already had Flicker API Key, so skipped this step. (p.2-3)
  8. (1.2) Checked and already had Flickr gem (1.0.2), so skipped this step. (p.3-8).
  9. (1.3) Created brand new rails project (flickr0606). (p.8-12)
  10. (1.4) Create brand new database, flickr0606_development. Also moved project under RAILSPASSION directory. (p.12-14)
  11. (1.5) Add Flickr settings to project's environment.rb file. Also added my pass key. (p.14-17)
  12. (1.6) Define a layout and stylesheet. I created a new layout file, application.rhtml. NOTE THAT NETBEANS FOUND A ERROR IN THE SUPPLIED FILE. Unclear how to fix it. Also created a brand new CSS file, flickr.css. (p.17-23)
  13. (1.7) Create a controller, flickr, but only after removing the two "require" statements in the config/environment.rb file. Also added supplied search method to flickr controller. (p.25-30)
  14. (1.8) Modified index.html.erb with supplied text, but Netbeans found 2 errors - unclear how to fix them. Then created brand new Partial, _photo, file, but Netbeans found 1 error - unclear how to fix it. (p.30-35)
  15. (1.9) Set URL routing: Modify routes.rb and renaming index.html. (p.35-38)
  16. (1.10) Ran the application and got the web page, but when I typed in "Netbeans and select "Find" I got "ArgumentError in FlickrController#search;
    wrong # of arguments(3 for 0)" (p.38-41)
  17. Watched: http://media.rubyonrails.org/video/flickr-rails-ajax.mov
  18. Found this: http://snippets.dzone.com/posts/show/3493
  19. Also Found this: http://weblogs.java.net/blog/bleonard/archive/2007/03/building_a_ruby.html
  20. Finally got it to run by running it from the command line. (p.41)
  21. (1.11) Copied spinner.gif to public/images directory. Also modified index.rhtml.erb file with supplied text. (p.41-44)
  22. Run it again. (6/6/2009: It worked so I packaged it up and emailed my last homework/lesson)





Sunday, May 31, 2009

Week 18: Rails Passion Course

  1. Rails Example Application -Depot Application (Week 18)
  2. 5536_rails_depot_app.zip (Unzip it in a directory of your choice and read lab document from /rails_depot_app/index.html to proceed) (5/31/09: Downloaded)
  3. Presentation - there is no presentation
  4. Resources
    o Rails code examples site
    + Ruby on Rails Open Source Projects website from wiki.rubyonrails.com
    + Top 29 Ruby on Rails Demos Example Code Samples
    + Dzone Snippets rubyonrails
    o Examples
    + Top 12 Ruby on Rails Tutorials from digitialmediaminute.com
    + Rails Petstore email

o Online lab document/ Change Log (This is the same document you will find in the hands-on lab zip file) (66 pages)
o Homework (Yes, We have Homework)

Week 17: Rails Passion Course

  1. Deployment (Week 17) (Topics covered: Deployment)
  2. 5538_rails_deploy.zip (Unzip it in a directory of your choice and read lab document from /rails_deploy/index.html to proceed)
  3. Resources: Deploying on GlassFish
    + GlassFish v2 and JRuby powering WorldcChange Comm (April 2008)
    + JRuby-on-Rails standalone and shared WARs in Glassfish screencast by Arun Gupta (Oct. 2007)
    + JRuby on Rails Rewrite of mediacast.sun.com launched (Jan. 2008)
    + Deploying JRuby applications with Java Web start article from infoq.com (March, 2008)
    + Rails and Java EE integration - Servlet co-bindled and invoked from Rails blog by Arun Gupta (April, 2008)
    + Rails and Java EE integration - Native Rails on GlassFish v3 blog by Arun Gupta (April 2008)
    o Warbler
    + Rails and Java EE integration - Warbler instead of Goldspike blog by Arun Gupta (April, 2008)
    + Wabler, A Little Birdie To Introduce Your Rails App to Java blog by Nick Sieger (Sep. 2007)
    + Warbler documentation from caldersphere.rubyforge.org
    o Goldspike
    + Goldspike homesite
    o JDBC
    + JDBC Connection Pooling for Rails on GlassFish blog by lkai Lan (Aug. 2008)
    o Presentations
    + Enterprise Ruby with JRuby on Rails presentation by Naoto Takai
  4. Presentation: PDF: 1 slide per page (OR) OpenOffice file (5 pages) (5/31/09: Read)
  5. Online lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (5/31/09: Did most of it/No Glassfish/Had problems with Glassfish)
  6. 5/31/09: No Homework

Week 16: Rails Passion Course

  1. Ajax (Week 16) (Topics covered: Ajax/JavaScript libraries in Rails, PrototypeHelper, ScriptaculousHelper, JavaScriptMacrosHelper, JavaScript related utility methods, Ruby JavaScript template)
  2. 5532_rails_ajax.zip (Unzip it in a directory of your choice and read lab document from /rails_ajax/index.html to proceed) (5/31/09: Downloaded)
  3. Resources
    o ActionView::Helpers::PrototypeHelper API from api.rubyonrails.org
    o ActionView::Helpers::ScriptaculousHelper API from api.rubyonrails.org
    o ActionView::Helpers::JavaScriptHelper API from api.rubyonrails.org
    o ActionView::Helpers::JavaScriptMacrosHelper from api.rubyonrails.org
    o Using Ajax With Ruby on Rails tutorial by Brian Leonard and Natalie Jeremy
    o jMaki on Rails blog by Arun Gupta (March, 2008)
  4. Homework ("To Be Provided") (5/31/09: None Yet)
  5. Presentation: PDF: 1 slide per page (OR) OpenOffice file (56 pages) (5/31/09: Scanned)
  6. Online lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (28 pages) (5/31/09: Read/No Homework)

Monday, May 25, 2009

Week 15: Rails Passion Course

  1. Testing & RSpec (Week 15) (Topics to be covered: Overview of Rails testing, Unit testing, Functional testing, Integration testing)
  2. 5535_rails_testing.zip (Unzip it in a directory of your choice and read lab document from /rails_testing/index.html to proceed) (5/25/09: Downloaded)
  3. Resources
    o Tutorials
    + About "A Guide to Testing the Rails" article from manuals.rubyonrails.com
    + Developing a Rails model using BDD + RSpec tutorial by Luke Redpath (8/06)
    o NetBeans tutorials
    + Ruby Testing NetBeans tutorial from wiki.netbeans.org
    + Screencast: RSpec and NetBeans by Nick Sieger (Feb. 2008)
    + Test-Driven Rails Development tutorial by Brian Leonard and Neth Stearns from netbeans.org (Dec. 2007)
    + Graphic guide to Rails on NetBeans: RSpec and Autotest from scratch tutorial (Nov. 2007)
    o References
    + Assert methods from ruby-doc.org
  4. Presentation: PDF: 1 slide per page OR OpenOffice file (28 pages) (5/25/09: Read)
o Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file)
o Homework (5/31/09: Finally finished it)

Week 14: Rails Passion Course

  1. REST Support (Week 14) (Topics to be covered: What is REST?, REST support in Rails, Format of the response via response_to)
  2. 5534_rails_rest.zip (Unzip it in a directory of your choice and read lab document from /rails_rest/index.html to proceed) (5/25/09: Downloaded)
  3. Resources
    o Tutorials
    + Designing RESTful Rails Applications screencast by Obie Fernandez from infoq.com (July, 2008)
    + Web Services, Rails-style blog by Jamis
    + Rails 1.2: REST admiration, HTTP lovefest, and UTF-8 celebrations article (Jan. 2007)
    + Rapid RESTful Rails Apps article by Myles Eftos (Feb. 2008)
    + Introduction to AWS (Amazon Web Services) for Ruby Developers from developer.amazon.com
    o API
    + ActionController::Resources from api.rubyonrails.org
    o Client
    + Ruby REST client
  4. Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (5/25/09: done)
  5. Presentation: PDF: 1 slide per page OR OpenOffice file (24 pages) (5/25/09: Read)
  6. Homework 14 (5/25/09: Done/Emailed to Sun)

Sunday, May 24, 2009

Week 13: Rails Passion Course

  1. Action View Helpers (Week 13) (Topics to be covered: Types of ActionView Helpers, FormHelper's, FormTagHelper's)
  2. 5533_rails_viewhelpers.zip (Unzip it in a directory of your choice and read lab document from /rails_viewhelpers/index.html to proceed) (5/24/09: Downloaded)
  3. Resources
    o ActionView::Helpers::FormHelper API from api.rubyonrails.org
    o ActionView::Helpers::FormTagHelper API from api.rubyonrails.org
  4. Lab and homework/Change Log (1 page) (5/24/09: Read)
  5. Online lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (5/24/09: Read)
  6. Presentation:PDF: 1 slide per page OR OpenOffice file (23 pages) (5/24/09: Read)
  7. Pre-class reading material (Action view helper tutorial) (11 pages) (5/24/09: Read)
  8. Monday: Starting HW13.
  9. Started up Netbeans, build databases, and migrated the database.
  10. Added "Gender" field to Student table.
  11. Homework 13 (5/25/09: Emailed)

Week 12: Rails Passion Course

  1. Action View Basics (Week 12) (Topics to be covered: Types of templates, ERb template, Builder template, JavaScriptGenerator template, Using sub-templates, Layouts, Partials)
  2. 5531_rails_actionview.zip (Unzip it in a directory of your choice and read lab document from /rails_actionview/index.html to proceed) (5/24/09: Downloaded)
  3. Resources
    o ActionView::Base API from api.rubyonrails.org
    o ActionView::Partials API from railsbrain.com
  4. Pre-class reading material (Action view tutorial) (5/24/09: Scanned it)
  5. Presentation: PDF: 1 slide per page OR OpenOffice file (29 pages) (5/24/09: Read)
  6. Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (5/24/09: Done)
  7. Homework (Combine the 2 partials into one file and use it in edit and new .html.erb files) (5/24/09: Created draft)

Thursday, May 14, 2009

May 15, 2009 Steps

  1. cucumber.bat features 2>&1 |tee o_ca
  2. ruby script/plugin install git://github.com/notahat/machinist.git
  3. gem install notahat-machinist

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.