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.


No comments:

Post a Comment