0
@@ -908,7 +908,7 @@ and then view them as a blog visitor at <a href="http://localhost:3000/blog">htt
0
<p>Notice how the <code>down</code> method calls are in reversed order of the <code>up</code> method calls.</p>
0
- <p>Save the file (⌘ S) and migrate to current (⌃ |
, option 3).</p>
0
+ <p>Save the file (⌘ S) and migrate to current (⌃ |
).</p>
0
<p>Be sure to modify the comments fixture file. Go there (⌘ T, press <code>cy</code>, choose <code>comments.yml</code>). Rename <code>name</code> to <code>author</code> and add a row for <code>author_url</code> for each comment. Check your tests again (⌃ \, choose option 1). All tests should pass.</p>
0
@@ -948,7 +948,7 @@ and then view them as a blog visitor at <a href="http://localhost:3000/blog">htt
0
<p>Notice how the <code>Remove / Add Column</code> command automagically determined in the <code>down</code> method the column type of column <code>published</code> to be a <code>boolean</code>. It determines this by looking at the current state of your <code>db/schema.rb</code> file.</p>
0
- <p>Save the file (⌘ S) and migrate to current (⌃ |
, option 3).</p>
0
+ <p>Save the file (⌘ S) and migrate to current (⌃ |
).</p>
0
<p>Now we need to modify the posts fixtures file. Go there (⌘ T, type <code>pyml</code>, choose <code>posts.yml</code>). Replace the line <code>published: true</code> by <code>published_at: 2008-1-1</code>.</p>
0
@@ -957,6 +957,32 @@ and then view them as a blog visitor at <a href="http://localhost:3000/blog">htt
0
<p>Modify the posts functional test, first go there (⇧ ⌥ ⌘ ↓, choose “Go to Functional Test”). Replace <code>:published => '1'</code> by <code>:published_at => Date.new(2008, 1, 1)</code>.</p>
0
+ <p>Modify the post model, first go there (⇧ ⌥ ⌘ ↓, choose “Go to Model”). Have the code look like:</p>
0
+ <p><pre class='syntax'><span class="keyword">class </span><span class="class">Post</span> <span class="punct"><</span> <span class="constant">ActiveRecord</span><span class="punct">::</span><span class="constant">Base</span>
0
+ <span class="ident">has_many</span> <span class="symbol">:comments</span>
0
+ <span class="keyword">def </span><span class="method">published</span>
0
+ <span class="punct">!</span><span class="constant">self</span><span class="punct">.</span><span class="ident">published_at</span><span class="punct">.</span><span class="ident">nil?</span>
0
+ <span class="keyword">end</span>
0
+ <span class="keyword">def </span><span class="method">published=</span><span class="punct">(</span><span class="ident">publish</span><span class="punct">)</span>
0
+ <span class="keyword">if</span> <span class="ident">publish</span>
0
+ <span class="constant">self</span><span class="punct">.</span><span class="ident">published_at</span> <span class="punct">=</span> <span class="constant">DateTime</span><span class="punct">.</span><span class="ident">now</span> <span class="keyword">if</span> <span class="constant">self</span><span class="punct">.</span><span class="ident">published_at</span><span class="punct">.</span><span class="ident">nil?</span>
0
+ <span class="keyword">else</span>
0
+ <span class="constant">self</span><span class="punct">.</span><span class="ident">published_at</span> <span class="punct">=</span> <span class="constant">nil</span>
0
+ <span class="keyword">end</span>
0
+ <span class="keyword">end</span>
0
+<span class="keyword">end</span></pre></p>
0
+ <p>Modify the <code>blog_controller.rb</code> file. Replace <code>Post.find_all_by_published(true)</code> by <code>Post.find(:all, :conditions => "published_at IS NOT NULL")</code>.</p>
0
+ <p>Finally, check your tests again (⌃ \). All tests should pass.</p>
0
<h1><span class="caps">TODO</span></h1>
Comments
No one has commented yet.