<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CSCI E-168 &#187; Announcements</title>
	<atom:link href="http://e168f09.plugh.org/category/announcements/feed/" rel="self" type="application/rss+xml" />
	<link>http://e168f09.plugh.org</link>
	<description>Building Web-based Software with Ruby and Ruby on Rails</description>
	<lastBuildDate>Sun, 13 Dec 2009 22:20:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick live code from Sunday Section</title>
		<link>http://e168f09.plugh.org/2009/12/13/quick-live-code-from-sunday-section/</link>
		<comments>http://e168f09.plugh.org/2009/12/13/quick-live-code-from-sunday-section/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 22:20:00 +0000</pubDate>
		<dc:creator>Jonathan</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=775</guid>
		<description><![CDATA[Attached is the quick and dirty multiple model form from today&#8217;s section.
Click here to download.
]]></description>
			<content:encoded><![CDATA[<p>Attached is the quick and dirty multiple model form from today&#8217;s section.</p>
<p><a href="http://e168f09.plugh.org/wp-content/uploads/2009/12/section.zip">Click here</a> to download.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/12/13/quick-live-code-from-sunday-section/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Form / Partial Example</title>
		<link>http://e168f09.plugh.org/2009/11/08/simple-form-partial-example/</link>
		<comments>http://e168f09.plugh.org/2009/11/08/simple-form-partial-example/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 22:29:41 +0000</pubDate>
		<dc:creator>Jonathan</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=648</guid>
		<description><![CDATA[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&#8217;t match
collection_select drop downs
named_scope and default_scope

Click here to download the completed application.
]]></description>
			<content:encoded><![CDATA[<p>Another completed project from the Sunday section.</p>
<p>This application makes use of the following:</p>
<ul>
<li>form_for</li>
<li>Partials for DRYness</li>
<li>has_many :through where tables and foreign keys don&#8217;t match</li>
<li>collection_select drop downs</li>
<li>named_scope and default_scope</li>
</ul>
<p><a href="http://e168f09.plugh.org/wp-content/uploads/2009/11/section.zip">Click here</a> to download the completed application.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/11/08/simple-form-partial-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice book chapter on REST</title>
		<link>http://e168f09.plugh.org/2009/11/01/nice-book-chapter-on-rest/</link>
		<comments>http://e168f09.plugh.org/2009/11/01/nice-book-chapter-on-rest/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 15:29:59 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=605</guid>
		<description><![CDATA[I think I&#8217;ve recommended this book before: Eldon Alameda&#8217;s Practical Rails Projects.
It has a sweet chapter on building a RESTful application, and shows very well how the controllers should be &#8220;rescoped&#8221; to work only on data that is appropriate. This &#8220;rescoping&#8221; is part of the requirements for Assignment 4 (requirement #5 about not letting users [...]]]></description>
			<content:encoded><![CDATA[<p>I think I&#8217;ve recommended this book before: Eldon Alameda&#8217;s Practical Rails Projects.</p>
<p>It has a sweet chapter on building a RESTful application, and shows very well how the controllers should be &#8220;rescoped&#8221; to work only on data that is appropriate. This &#8220;rescoping&#8221; is part of the requirements for Assignment 4 (requirement #5 about not letting users edit data &#8220;owned&#8221; by another user).</p>
<p>That chapter is a free download: </p>
<p>http://www.apress.com/book/view/1590597818</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/11/01/nice-book-chapter-on-rest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Assignment 4 download available</title>
		<link>http://e168f09.plugh.org/2009/10/31/assignment-4-download-available/</link>
		<comments>http://e168f09.plugh.org/2009/10/31/assignment-4-download-available/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 06:37:06 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=596</guid>
		<description><![CDATA[For those of you who burn the midnight oil, as I do . . .
The download for Assignment 4 (and 5) is available on the downloads page. I&#8217;ll send an e-mail tomorrow morning (the Harvard e-mail service is unavailable from 1 AM to 4 AM!!).
]]></description>
			<content:encoded><![CDATA[<p>For those of you who burn the midnight oil, as I do . . .</p>
<p>The download for Assignment 4 (and 5) is available on the downloads page. I&#8217;ll send an e-mail tomorrow morning (the Harvard e-mail service is unavailable from 1 AM to 4 AM!!).</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/31/assignment-4-download-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What gets validated?</title>
		<link>http://e168f09.plugh.org/2009/10/26/what-gets-validated/</link>
		<comments>http://e168f09.plugh.org/2009/10/26/what-gets-validated/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 19:45:28 +0000</pubDate>
		<dc:creator>Antony</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=523</guid>
		<description><![CDATA[Say you have a model called Match with attributes wins and losses, both of type integer.  To this model you add validation to ensure these attributes are only integers:

class Match &#60; ActiveRecord::Base
 validates_numericality_of :wins, :only_integer =&#62; true
 validates_numericality_of :losses, :only_integer =&#62; true
end

Then, in script/console:

&#62;&#62; m = Match.new
=&#62; #&#60;Match id: nil, wins: nil, losses: nil, created_at: [...]]]></description>
			<content:encoded><![CDATA[<p>Say you have a model called Match with attributes wins and losses, both of type integer.  To this model you add validation to ensure these attributes are only integers:</p>
<pre class="brush: ruby;">
class Match &lt; ActiveRecord::Base
 validates_numericality_of :wins, :only_integer =&gt; true
 validates_numericality_of :losses, :only_integer =&gt; true
end
</pre>
<p>Then, in script/console:</p>
<pre class="brush: bash;">
&gt;&gt; m = Match.new
=&gt; #&lt;Match id: nil, wins: nil, losses: nil, created_at: nil, updated_at: nil&gt;
&gt;&gt; m.wins = &quot;seven&quot;
=&gt; &quot;seven&quot;
&gt;&gt; m.losses = &quot;five&quot;
=&gt; &quot;five&quot;
&gt;&gt; m
=&gt; #&lt;Match id: nil, wins: 0, losses: 0, created_at: nil, updated_at: nil&gt;
&gt;&gt; m.valid?
=&gt; false
</pre>
</pre>
<p>The strings have been cast as integers, but why does the validation fail?  The answer is that ActiveRecord stores much more information than what shows up as instance attributes.</p>
<pre class="brush: bash;">
&gt;&gt; m.attributes_before_type_cast
=&gt; {&quot;created_at&quot;=&gt;nil, &quot;losses&quot;=&gt;&quot;five&quot;, &quot;updated_at&quot;=&gt;nil, &quot;wins&quot;=&gt;&quot;seven&quot;}
</pre>
</pre>
<p>An indepth look at all of the machinery of ActiveRecord might be a course in itself, but I thought this would provide a taste of the breadth and depth of the ORM.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/26/what-gets-validated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating existing data</title>
		<link>http://e168f09.plugh.org/2009/10/26/migrating-existing-data/</link>
		<comments>http://e168f09.plugh.org/2009/10/26/migrating-existing-data/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 19:19:10 +0000</pubDate>
		<dc:creator>Antony</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=519</guid>
		<description><![CDATA[Agile Web Development with Rails, 17.4 and 17.5, covers this subject.
On page 307 of the PDF, Migrating Data with Migrations, the basic scheme you might use is demonstrated.  As another example, suppose I create a users table and model:

$ ./script/generate model users first_name:string last_name:string

The migration looks like this:

class CreateUsers &#60; ActiveRecord::Migration
 def self.up
   [...]]]></description>
			<content:encoded><![CDATA[<p>Agile Web Development with Rails, 17.4 and 17.5, covers this subject.</p>
<p>On page 307 of the PDF, Migrating Data with Migrations, the basic scheme you might use is demonstrated.  As another example, suppose I create a users table and model:</p>
<pre class="brush: bash;">
$ ./script/generate model users first_name:string last_name:string
</pre>
<p>The migration looks like this:</p>
<pre class="brush: ruby;">
class CreateUsers &lt; ActiveRecord::Migration
 def self.up
   create_table :users do |t|
     t.string :first_name
     t.string :last_name

     t.timestamps
   end
 end

 def self.down
   drop_table :users
 end
end
</pre>
<p>After adding a number of users, it becomes clear that a full_name attribute would be very useful:</p>
<pre class="brush: bash;">
$ ./script/generate migration AddFullNameToUser full_name:string
</pre>
<p>This new migrations looks like this:</p>
<pre class="brush: ruby;">
class AddFullNameToUser &lt; ActiveRecord::Migration
  def self.up
    add_column :users, :full_name, :string
  end

  def self.down
    remove_column :users, :full_name
  end
end
</pre>
<p>Before running it, I add the line to update the users:</p>
<pre class="brush: ruby;">
class AddFullNameToUser &lt; ActiveRecord::Migration
  def self.up
    add_column :users, :full_name, :string
    User.find(:all).each do |u|
      u.full_name = u.first_name + ' ' + u.last_name
      u.save!
    end
  end

  def self.down
    remove_column :users, :full_name
  end
end
</pre>
<p>An important note here:  I did not use update_all because string concatenation is not portable between database engines (|| for Oracle, postgres and sqlite3, + for SQL Server and Sybase,  concat for MySQL, etc).</p>
<p>As John demonstrated in his migrations 3 example, depending on what you are trying to accomplish, the down method may not be data preserving.</p>
<p>Beyond the above and similar data manipulation, section 17.5 covers ways to execute fragments of native SQL or arbitrary SQL.  Using this functionality is beyond the scope of this course and of course has the significant downside of being much less portable.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/26/migrating-existing-data/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Additional Standalone ActiveRecord Example</title>
		<link>http://e168f09.plugh.org/2009/10/11/additional-standalone-activerecord-example/</link>
		<comments>http://e168f09.plugh.org/2009/10/11/additional-standalone-activerecord-example/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 21:43:10 +0000</pubDate>
		<dc:creator>Jonathan</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=411</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>In the Sunday section, we re-created the previous example application using ActiveRecord. This is <em>very</em> similar to the examples from Lecture 6 in the download section, except that this was written with an emphasis on test driven development.</p>
<p>It includes examples of:</p>
<ul>
<li>Migrations</li>
<li>Simple Seed Data</li>
<li>Fancy Finders</li>
<li>Validations and Validation Testing</li>
<li>One to Many Relationships</li>
</ul>
<p>For the sake of time, there were no many to many relationships. Examples of m2m can be found in the download section.</p>
<p>Use rake -T to view the rake tasks. Use &#8220;rake db:migrate&#8221; to run the migrations, and &#8220;rake test&#8221; to run the tests.</p>
<p>Run &#8220;ruby section.rb&#8221; to run the demo code. Modify section.rb to play around with the finished results.</p>
<p>You can <a href='http://e168f09.plugh.org/wp-content/uploads/2009/10/activerecord-section.zip'>click here</a> to download the complete source code.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/11/additional-standalone-activerecord-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command line sqlite</title>
		<link>http://e168f09.plugh.org/2009/10/10/command-line-sqlite/</link>
		<comments>http://e168f09.plugh.org/2009/10/10/command-line-sqlite/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 09:57:58 +0000</pubDate>
		<dc:creator>Antony</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=388</guid>
		<description><![CDATA[Execute the command sqlite3 at the command prompt passing the file name of the database:
$ sqlite3 &#60;database name&#62;.sqlite3
You should see output similar to the following:
SQLite version 3.6.10
Enter &#8220;.help&#8221; for instructions
Enter SQL statements terminated with a &#8220;;&#8221;
sqlite&#62;
Check that the version is correct.  People running sqlite3 in emacs may need to set sql-sqlite-program.
Enter &#8216;.help&#8217; to see the [...]]]></description>
			<content:encoded><![CDATA[<p>Execute the command sqlite3 at the command prompt passing the file name of the database:</p>
<blockquote><p>$ sqlite3 &lt;database name&gt;.sqlite3</p></blockquote>
<p>You should see output similar to the following:</p>
<blockquote><p>SQLite version 3.6.10<br />
Enter &#8220;.help&#8221; for instructions<br />
Enter SQL statements terminated with a &#8220;;&#8221;<br />
sqlite&gt;</p></blockquote>
<p>Check that the version is correct.  People running sqlite3 in emacs may need to set sql-sqlite-program.</p>
<p>Enter &#8216;.help&#8217; to see the list of commands that provide information or set options. Input starting with a &#8216;.&#8217; (period) signals non-SQL and should be one of those commands.  All other input will be interpreted as SQL and should be terminated with a &#8216;;&#8217; (semi-colon).</p>
<p>Enter &#8216;.quit&#8217; to exit.  Some other commands you will likely find useful are &#8216;.headers&#8217;, &#8216;.tables&#8217;, and &#8216;.schema&#8217;.</p>
<p>When using rails with sqlite3, this same functionality can be started with &#8217;script/dbconsole&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/10/command-line-sqlite/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Best Books on Rails</title>
		<link>http://e168f09.plugh.org/2009/10/07/best-books-on-rails/</link>
		<comments>http://e168f09.plugh.org/2009/10/07/best-books-on-rails/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 02:21:05 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=371</guid>
		<description><![CDATA[Compared to Ruby, the pickings are slim for great books that try to explain core Rails from end-to-end. Generally, each good book on Rails approaches a part of the Rails elephant.
Here are the ones I recommend:
Ruby, Thomas, and Hansson, Agile Web Development with Rails, 3d ed. (Amazon). If you&#8217;re taking this course, you should own [...]]]></description>
			<content:encoded><![CDATA[<p>Compared to Ruby, the pickings are slim for great books that try to explain core Rails from end-to-end. Generally, each good book on Rails approaches a part of the Rails elephant.</p>
<p>Here are the ones I recommend:</p>
<p>Ruby, Thomas, and Hansson, <strong>Agile Web Development with Rails</strong>, 3d ed. (<a href="http://www.amazon.com/gp/product/1934356166?ie=UTF8&#038;tag=ce1-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1934356166">Amazon</a>). If you&#8217;re taking this course, you should own this already. AWDR touches all the bases, but still has sections that drive readers a little bit crazy. But . . . essential.</p>
<p>David Griffiths, <strong>Head First Rails</strong> (<a href="http://www.amazon.com/gp/product/0596515774?ie=UTF8&#038;tag=ce1-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0596515774">Amazon</a>; <a href="http://proquest.safaribooksonline.com.ezp-prod1.hul.harvard.edu/9780596157302" target="_blank">Safari</a>). If you&#8217;re a learn-by-doing person and have the time to work through a book, this is the one. The Head First books know a lot about triggering learning in your brain through exercises and pictures. I think this book is most worthwhile very early in your experience with Rails; afterwards it may feel redundant.</p>
<p>Eldon Alameda, <strong>Practical Rails Projects</strong> (<a href="http://www.amazon.com/gp/product/1590597818?ie=UTF8&#038;tag=ce1-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1590597818">Amazon</a>). The examples in this book are real-world and slick. Almeda has a good way at demonstrating how quickly you can get stuff done with Rails, selected Gems, and Rails plugins. A lot of good stuff on integrating Ajax/JavaScript with Rails.</p>
<p>Brad Ediger, <strong>Advanced Rails</strong> (<a href="http://www.amazon.com/gp/product/0596510322?ie=UTF8&#038;tag=ce1-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0596510322">Amazon</a>; <a href="http://proquest.safaribooksonline.com.ezp-prod1.hul.harvard.edu/9780596510329" target="_blank">Safari</a>). The natural followup to AWDR for readers who really have to get it right. The best aspect of this book is that it dares to go into some depth on topics such as the database, security, and performance.</p>
<p>Dan Chak, <strong>Enterprise Rails</strong> (<a href="http://www.amazon.com/gp/product/0596515200?ie=UTF8&#038;tag=ce1-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0596515200">Amazon</a>; <a href="http://proquest.safaribooksonline.com.ezp-prod1.hul.harvard.edu/9780596515201" target="_blank">Safari</a>). The meat of this book is about leveraging the underlying power of your database, using features that are a bit out of the Rails mainstream (composite keys; views; triggers; etc.). The book also benefits from understanding from the get-go that your new shiny enterprise app should be exposing and consuming services (SOAP, REST).</p>
<p>Obie Fernandez, <strong>The Rails Way</strong> (<a href="http://www.amazon.com/gp/product/0321445619?ie=UTF8&#038;tag=ce1-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321445619">Amazon</a>; <a href="http://proquest.safaribooksonline.com.ezp-prod1.hul.harvard.edu/9780321445612" target="_blank">Safari</a>). This book is a ginormous grab bag of real-world scar tissue on just about every Rails topic. Want to know how and when the Rails Class Loader runs? Check. Should RESTful resource be nested deeply? Check. What&#8217;s wrong with CookieStore? Check. To buy after completing two Rails applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/07/best-books-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Download of Ruby 1.9 docs with Rails docs</title>
		<link>http://e168f09.plugh.org/2009/10/02/download-of-ruby-1-9-docs-with-rails-docs/</link>
		<comments>http://e168f09.plugh.org/2009/10/02/download-of-ruby-1-9-docs-with-rails-docs/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 14:37:52 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://e168f09.plugh.org/?p=351</guid>
		<description><![CDATA[I know that Windows users are hampered because ri is not properly installed.
If you&#8217;d like a nicely-formatted download of Ruby and Rails docs, try http://railsapi.com/
You can customize what you want, and include other components, adding docs for, say, the popular Hpricot HTML/XML parsing library (and much else).
They package docs for Rails 2.3.4 (rather than 2.3.3, [...]]]></description>
			<content:encoded><![CDATA[<p>I know that Windows users are hampered because ri is not properly installed.</p>
<p>If you&#8217;d like a nicely-formatted download of Ruby and Rails docs, try http://railsapi.com/</p>
<p>You can customize what you want, and include other components, adding docs for, say, the popular Hpricot HTML/XML parsing library (and much else).</p>
<p>They package docs for Rails 2.3.4 (rather than 2.3.3, which we&#8217;re using) which should be fine.</p>
<p>For Rails, a student reminds me that you can run &#8220;gem server&#8221; in one window, and then browse to http://localhost:8808/ to see docs for all gems you&#8217;ve installed (but not the core/standard Ruby docs).</p>
]]></content:encoded>
			<wfw:commentRss>http://e168f09.plugh.org/2009/10/02/download-of-ruby-1-9-docs-with-rails-docs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
