Permalink
Browse files

fix "redirect_to topics_path" step to make students' brains bleed les…

…s (thanks Nick)
  • Loading branch information...
1 parent c430cc9 commit 3aa2f5667291dd8dd781aa24a38ebf96f9d85811 @alexch alexch committed Nov 20, 2011
Showing with 10 additions and 20 deletions.
  1. +10 −20 lessons/17.yaml
View
@@ -12,30 +12,20 @@ goal: |
steps: |
Open `app/controllers/topics_controller.rb` and look at the create
- method (it looks like this):
-
+ method.
+
+ Find the line:
+
<pre class="code">
:::ruby
- def create
- @topic = Topic.new(params[:topic])
-
- respond_to do |format|
- if @topic.save
- format.html { redirect_to @topic, :notice => 'Topic was successfully created.' }
- format.json { render :json => @topic, :status => :created, :location => @topic }
- else
- format.html { render :action => "new" }
- format.json { render :json => @topic.errors, :status => :unprocessable_entity }
- end
- end
- end
+ format.html { redirect_to @topic, :notice => 'Topic was successfully created.' }
</pre>
-
- Change the line:
+
+ and change "@topic" to "topics_path" like this:
<pre class="code">
:::ruby
- format.html { redirect_to @topic, :notice => 'Topic was successfully created.' }
+ format.html { redirect_to topics_path, :notice => 'Topic was successfully created.' }
</pre>
so that the file looks like this:
@@ -57,11 +47,11 @@ steps: |
end
</pre>
- Look at it at [http://localhost:3000](http://localhost:3000).
+ Look at it at <http://localhost:3000>.
explanation: |
* `format.html { redirect_to topics_path, :notice => 'Topic was successfully created.' }`:
* `format.html` means that the server should send html back to the browser
- * `redirect_to topics_path` means show the topics list page when we're done creating a topic
+ * `redirect_to topics_path` means show the **topics list page** when we're done creating a topic
* `:notice => 'Topic was successfully created.'` puts the message into the flash so it will be displayed on the topics list

0 comments on commit 3aa2f56

Please sign in to comment.