Archive

Author Archive

Quick live code from Sunday Section

December 13th, 2009 Jonathan No comments

Attached is the quick and dirty multiple model form from today’s section.

Click here to download.

Categories: Announcements Tags:

Simple Form / Partial Example

November 8th, 2009 Jonathan No comments

Another completed project from the Sunday section.

This application makes use of the following:

  • form_for
  • Partials for DRYness
  • has_many :through where tables and foreign keys don’t match
  • collection_select drop downs
  • named_scope and default_scope

Click here to download the completed application.

Categories: Announcements Tags:

Additional Standalone ActiveRecord Example

October 11th, 2009 Jonathan No comments

In the Sunday section, we re-created the previous example application using ActiveRecord. This is very similar to the examples from Lecture 6 in the download section, except that this was written with an emphasis on test driven development.

It includes examples of:

  • Migrations
  • Simple Seed Data
  • Fancy Finders
  • Validations and Validation Testing
  • One to Many Relationships

For the sake of time, there were no many to many relationships. Examples of m2m can be found in the download section.

Use rake -T to view the rake tasks. Use “rake db:migrate” to run the migrations, and “rake test” to run the tests.

Run “ruby section.rb” to run the demo code. Modify section.rb to play around with the finished results.

You can click here to download the complete source code.

Categories: Announcements Tags:

Class, Module and Test Example

September 27th, 2009 Jonathan 10 comments

In the Sunday section, we created a small application that several students requested the final source for. It includes examples of:

  • Class inheritance
  • Raising and catching exceptions
  • Using a module via include and extend
  • Testing using Test::Unit
  • Spreading code between multiple files
  • Using method_missing to dynamically add methods
  • How to tune a Ukulele for fun and profit

I tried to make use of as much of the last two lectures as possible. If you have any questions about how this works, or why things are done the way they are, feel free to comment below.
You can click here to downloaded the completed source code.

Run “ruby section.rb” to actually run the application. Edit this file as you see fit.

Run “ruby instrument_test.rb” to run the tests.

Categories: Announcements Tags: