Friday, November 5, 2010
Friday, October 29, 2010
Emerald City P-G: Agile Web Development with Rails (4th Edition)
- Already had 3 sessions (Saturdays, 10am-Noon) in Peachtree Corners.
- Misc Web Links for Installing Rails with RVM:
- http://amerine.net/2010/02/24/rvm-rails3-ruby-1-9-2-setup.html
- http://stackoverflow.com/questions/3648392/install-rails-3-on-osx-with-rvm
- http://www.cowboycoded.com/2010/06/11/gem-install-mysql-on-mac-osx-leopard-with-rvm/
- http://blog.mhartl.com/2010/02/19/some-rvm-gotchas/
- ============
- http://kconrails.com/2009/12/30/restful-tests-with-shoulda/
- http://thewebfellas.com/blog/2007/12/10/rspec-autotest-and-snarl-on-windows
- http://stackoverflow.com/questions/1386562/how-to-get-started-on-tdd-with-ruby-on-rails
- ============
Wednesday, June 3, 2009
Week 21 "Optional 6": Rails Passion Course
- Rails Example Application - TimeTracker Application (Week 21/Option 6)
- Presentation:PDF: 1 slide per page (OR)OpenOffice file: None
- Homework: None
- Resources
o Ruby Time Tracker homesite from code.google.com/rubytime - 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)
Week 21 "Optional 5": Rails Passion Course
- Rails Example Application - FreeMIS Application (Week 21/Optional 5)
- Presentation:PDF: 1 slide per page (OR) OpenOffice file: None
- Resources
o FreeMIS homesite from www.freemis.net - Homework: None
- 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) - 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
- Rails Example Application - Substruct Application (ECommerce Application) (Week 21/Optional 4)
- Presentation - there is no presentation.
- Resources
o Substruct homesite
o Installing Substruct blog - Homework: 6/3/2009: Checked/None Yet.
- 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) Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (6/3/2009: Started) - Had problems so deferred.
Week 21 "Optional 3": Rails Passion Course
- Rails Example Application - Typo Application (Week 21/Optional 3)
- Presentation - there is no presentation
- Homework - tbd (None yet)
- Resources
o typo homesite from www.typosphere.org - 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)
Week 21 "Optionals/Empties": Rails Passion Course
- Ruby Gems (Week 21/Optional 1)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Download: None
- Lab/Change Log: None
- Resources
o RubyGems Manual from rubygems.org - Rails Security (Week 21/Optional 2)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Download: None
- Lab/Change Log: None
- Resources
o Ruby on Rails Security Guide document from www.quarkruby.com - Caching (Week 21/Optional 7)
- Link goes back to TOC, so done.
- Performance (Week 21/Optional 8)
- Download: None
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Lab/Change Log: None
- Resources: None
- Action Mailer (Week 21/Optional 9)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Download: None
- Lab/Change Log: None
- Resources: Action Mailer from api.rubyonrails.org
- Rails and Other Web Technologies (Week 21/Optional 10)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Download: None
- Lab/Change Log: None
- Resources: jMaki on Rails blog by Arun Gupta (March, 2008)
- Plug-in (Week 21/Optional 11)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Download: None
- Lab/Change Log: None
- Resources: None
- Misc Topics (Week 21/Optional 12)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file: None
- Download: None
- Lab/Change Log: None
- Resources
- RubyConf 2007 from rubyconf2007.confreaks.com
Week 20: Rails Passion Course
- Rails Example Application - Redmine Application (Week 20)
- Presentation - there is no presentation
- 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) - Homework: "TBD
" (Nothing Yet) - Resources
o Redmine homesite
o Redmine sample application from www.redmine.org - 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
- Rails Example Application - Flickr Application (Week 19)
- Presentation - there is no presentation.
- Resources - there is no resources.
- Homework - There is no Homework this week/unit.
- 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) 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) - (1.1) Already had Flicker API Key, so skipped this step. (p.2-3)
- (1.2) Checked and already had Flickr gem (1.0.2), so skipped this step. (p.3-8).
- (1.3) Created brand new rails project (flickr0606). (p.8-12)
- (1.4) Create brand new database, flickr0606_development. Also moved project under RAILSPASSION directory. (p.12-14)
- (1.5) Add Flickr settings to project's environment.rb file. Also added my pass key. (p.14-17)
- (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)
- (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)
- (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)
- (1.9) Set URL routing: Modify routes.rb and renaming index.html. (p.35-38)
- (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)
- Watched: http://media.rubyonrails.org/video/flickr-rails-ajax.mov
- Found this: http://snippets.dzone.com/posts/show/3493
- Also Found this: http://weblogs.java.net/blog/bleonard/archive/2007/03/building_a_ruby.html
- Finally got it to run by running it from the command line. (p.41)
- (1.11) Copied spinner.gif to public/images directory. Also modified index.rhtml.erb file with supplied text. (p.41-44)
- 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
- Rails Example Application -Depot Application (Week 18)
- 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) - Presentation - there is no presentation
- 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
- Deployment (Week 17) (Topics covered: Deployment)
- 5538_rails_deploy.zip (Unzip it in a directory of your choice and read lab document from
/rails_deploy/index.html to proceed) - 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 - Presentation: PDF: 1 slide per page (OR) OpenOffice file (5 pages) (5/31/09: Read)
- 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)
- 5/31/09: No Homework
Week 16: Rails Passion Course
- Ajax (Week 16) (Topics covered: Ajax/JavaScript libraries in Rails, PrototypeHelper, ScriptaculousHelper, JavaScriptMacrosHelper, JavaScript related utility methods, Ruby JavaScript template)
- 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) - 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) - Homework ("To Be Provided") (5/31/09: None Yet)
- Presentation: PDF: 1 slide per page (OR) OpenOffice file (56 pages) (5/31/09: Scanned)
- 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
- Testing & RSpec (Week 15) (Topics to be covered: Overview of Rails testing, Unit testing, Functional testing, Integration testing)
- 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) - 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 - Presentation: PDF: 1 slide per page OR OpenOffice file (28 pages) (5/25/09: Read)
o Homework (5/31/09: Finally finished it)
Week 14: Rails Passion Course
- REST Support (Week 14) (Topics to be covered: What is REST?, REST support in Rails, Format of the response via response_to)
- 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) - 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 - Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (5/25/09: done)
- Presentation: PDF: 1 slide per page OR OpenOffice file (24 pages) (5/25/09: Read)
- Homework 14 (5/25/09: Done/Emailed to Sun)
Sunday, May 24, 2009
Week 13: Rails Passion Course
- Action View Helpers (Week 13) (Topics to be covered: Types of ActionView Helpers, FormHelper's, FormTagHelper's)
- 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) - Resources
o ActionView::Helpers::FormHelper API from api.rubyonrails.org
o ActionView::Helpers::FormTagHelper API from api.rubyonrails.org - Lab and homework/Change Log (1 page) (5/24/09: Read)
- Online lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (5/24/09: Read)
- Presentation:PDF: 1 slide per page OR OpenOffice file (23 pages) (5/24/09: Read)
- Pre-class reading material (Action view helper tutorial) (11 pages) (5/24/09: Read)
- Monday: Starting HW13.
- Started up Netbeans, build databases, and migrated the database.
- Added "Gender" field to Student table.
- Homework 13 (5/25/09: Emailed)
Week 12: Rails Passion Course
- Action View Basics (Week 12) (Topics to be covered: Types of templates, ERb template, Builder template, JavaScriptGenerator template, Using sub-templates, Layouts, Partials)
- 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) - Resources
o ActionView::Base API from api.rubyonrails.org
o ActionView::Partials API from railsbrain.com - Pre-class reading material (Action view tutorial) (5/24/09: Scanned it)
- Presentation: PDF: 1 slide per page OR OpenOffice file (29 pages) (5/24/09: Read)
- Online lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (5/24/09: Done)
- 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
- cucumber.bat features 2>&1 |tee o_ca
- ruby script/plugin install git://github.com/notahat/machinist.git
- gem install notahat-machinist
Friday, April 24, 2009
Week 11: Rails Passion Course
- 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)) - 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) - 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 - Presentation - PDF: 1 slide per page (OR) OpenOffice file (47 pages) (4/27/2009: Done)
- Online Lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (93 pages)
- EXERCISE 0: Start MySQL database server. (p.2)
- EXERCISE 1: Requests and Parameters I (p.2-15)
- (1.0) Open and run "helloworld" sample application (p.2-4)
- (1.1) Observe parameters in development log. (p.4-6)
- (1.2) Modify the controller (p.6-9)
- (1.3) Pass the parameters through URL (p.9-11)
- (1.4) Observe the parameters in development log (p.11-12)
- (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"
- EXERCISE 2: Request and Parameters II (p.16-34)
- (2.0) Open and run "helloname" sample application project. (p.16-19)
- (2.1)Observe parameters in development log. (p.19-22)
- (2.2) Study how user input data is collected as parameters (p.22-25)
- (2.3) Study how parameters are accessed in the controller (p.25-26)
- (2.4) Add another column to the table through migration (p.26-30)
- (2.5) Modify the code of index.html.erb and respond.html.erb files. (p.30-31)
- (2.6) Run the helloname application. (p.31-33)
- (2.7) Observe the parameters in development log. (p.33-34)
- EXERCISE 3: Session and Flash (p.34-63)
- (3.1) Use session. (p.34-40)
- (3.2) Use ActiveRecordStore to maintain session data (p.40-56)
- (3.3) Use Flash (p.56-63)
- EXERCISE 4: Rendering (p.63-72)
- (4.1) Use render :text (p.64-66)
- (4.2) Use render :action => :respond (p.66-68)
- (4.3) Use render :action => 'respond" (p.68-70)
- (4.4) Use render :template (p.70-72)
- EXERCISE #5: User refresh problem with "render" - Use "redirect_to" (p.72-87)
- (5.1) Observe the problem of using render :action=>'list' when a user press "Refresh" (p.73-80)
- (5.2) Correct the problem by using redirect :action=>'list' instead (p.80-87)
- EXERCISE #6: Routing Basics (p.87-
- (6.1) Use Rails Console (for routing experimentation) (p.87-88)
- (6.2) Named routes (p.88-92)
- Homework
Tuesday, April 21, 2009
Week 10: Rails Passion Course
- Week 10: ActiveRecord Associations Basics (Topics covered: What is an Association?, Auto-generated methods, Cardinality, Unsaved objects and association)
- 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 - 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) - Presentation - PDF: 1 slide per page (OR) OpenOffice file (22 pages)
- Online Lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (84 pages)
- EXERCISE #0: Start MySQL database server (p.g2) (4/21/2009: done)
- EXERCISE #1: Add one-to-many association to rubyweblog application. (p.2-28)
- (1.1) Create Comment Model class (p.3-6)
- (1.2) Migrate database (p.6-7)
- (1.3) Add association macros to the Model classes (p.8-11)
- (1.4) Modify controller (p.11-15)
- (1.5) Modify [view] templates (p.15-17)
- (1.6) Save the changes (p.17-18)
- (1.7) Refresh the browswer and perform user operation (p.19-21)
- (1.8) Observing the database tables (p.22-26)
- (1.9) Use Rails Console (p.26-28)
- EXERCISE #2: Options for has_many (p.28-46)
- (2.0) Create fresh test data using migration (p.28-33)
- (2.1) Exercise :order option (p.34-39)
- (2.2) Exercise :destroy option (p.39-46)
- EXERCISE #3: Add many-to-many association to rubyweblog application (p.46-65)
- (3.1) Create Category model class (p.46-49)
- (3.2) Create "categories_posts" table through migration (p.49-55)
- (3.3) Add many-to-many relationship between Post and Category models (p.55-58)
- (3.4) Create test data through migration (p.59-64)
- (3.5) Use Rails Console (p.64-65)
- EXERCISE #4: Add many-to-many association to rubyweblog application using through - not ready yet
- (4.1) Recreate rubyweblog_development database (p.66-68)
- (4.2) Remove migration files that are not needed (p.68-69)
- (4.3) Create a join model (p.70-73)
- (4.4) Modify Post and Category models (p.73-75)
- (4.5) Create test data through migration (p.75-79)
- (4.6) Verify that the data tables are created correctly (p.79-83)
- (4.7) Use Rails Console (p.83-84)
- Finished Exercises (4:30pm)
- Homework (p.84)
Sunday, April 19, 2009
Week 9: Rails Passion Course
- 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)
- Week 9 Resources
- Basics
- ActiveRecord from api.rubyonrails.org
- ActiveRecord::Base API from api.rubyonrails.org
- ActiveRecord tutorial screencast by Gregg (July 2007)
- Advanced ActiveRecord presentation by Obie Fernandez
- Validation
- ActiveRecord::Validations::ClassMethods API document from rubyonrails.com
- Various examples from railsbrains.com
- Migration
- ActiveRecord::Migration API document from railsbrains.com
- Generate a migration from an existing MySQL database posting in ruby-forum.com
- 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) Presentation --PDF: 1 slide per page (OR) OpenOffice file (44 pages) (4/21/09: Read) - Online Lab/Change Log document (This is the same document you will find in the hands-on lab zip file) (105 pages)
- EXERCISE #0: Start MySQL database server. (p.2)
- EXERCISE #1: Creation of ActiveRecord Objects (p.2-39)
- (1.1) Create a new NetBeans project (with JRuby 1.1.4 and WEBrick) (p.3-6)
- (1.2) Create database (p.6-7)
- (1.3) Generate Model (3 attributes) (p.8-10)
- (1.4) Create database table through migration (p.10-19)
- (1.5) Create ActiveRecord objects through Rails Console (p.20-28)
- (1.6) Create database table rows through migration (p.29-39)
- EXERCISE #2: ActiveRecord#find (p.40-44)
- (2.1) find(:all) with various options (p.40-42)
- (2.1.1) With limit, offset, select options (p.40)
- (2.1.2) With order parameter (p.40-41)
- (2.1.3) With conditions parameter (p.41-42)
- (2.2) find(:first) (p.42)
- (2.3) find() with id (p.42)
- (2.4) Dynamic attribute-based finders (p.42-43)
- (2.5) find_by_sql method (p.43)
- (2.6) find_or_create_by_
method (p.43-44) - (2.7) find() with params (44) -- EMPTY/SKIPPED
- EXERCISE #3: Validation (p.44-75)
- (3.1) Delete all rows of the "users" table through migration (p.44-49)
- (3.2) Perform validation using validation helpers (p.50-60)
- (3.3) Add email field to the users table (p.61-69)
- (3.4) Add validation logic for the "email" field (p.70-71)
- (3.5) Perform validation testing on the email field (p.72-75)
- EXERCISE #4: Migrations (p.76-105)
- (4.1) Add a new column (p.76)
- (4.2) Rename a column - chane "email" to "email_addr" (p.76-83)
- (4.3) Roll back the change - change "email_addr" to "email" (p.84-89)
- (4.4) Display "schema.rb" file that maintains the current migration number (p.90-91)
- (4.5) Exercise with multiple veresions of migration files (p.92-105)
- EXERCISE #5: Statistics (p.106-107)
- EXERCISE #6: Callbacks (p.108--114)
- (6.1) Add callback to the Model (p.108-114)
- FINISHED EXERCISES (11:38am on 4/21/2009)
- Homework (p.115)
- 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) ========================== - HW9-part 2: Validation: Add the following validation logic for the credit_card field.
- It has to be unique.
- User can enter the credit card format in the following format. The x has to be numeric value.
- xxxx-xxxx-xxxx-xxxx (format #1)
- xxxx xxxx xxxx xxxx (format #2)
- xxxxxxxxxxxxxxxx (format #3) NOTE: 16 digits
- 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 - 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.
Subscribe to:
Posts (Atom)