aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2013-08-16 07:54:09 +1000
committerRyan Bigg <radarlistener@gmail.com>2013-08-16 07:54:09 +1000
commitdba4c6fe539c24ec1beb106e34f37f3cd0632022 (patch)
treebf74b1b191541ad9bd903da377ffebd11f1cf3c0
parent97d5ccf4f144b0fe93e9d033a516ac04eac5c7a8 (diff)
downloadrails-dba4c6fe539c24ec1beb106e34f37f3cd0632022.tar.gz
rails-dba4c6fe539c24ec1beb106e34f37f3cd0632022.tar.bz2
rails-dba4c6fe539c24ec1beb106e34f37f3cd0632022.zip
[getting started] Don't define resources :posts a second time + clarify messaging around 'Showing Posts' section
-rw-r--r--guides/source/getting_started.md18
1 files changed, 4 insertions, 14 deletions
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index c84c971f47..a191820d1c 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -573,18 +573,7 @@ whether the model was saved or not.
If you submit the form again now, Rails will complain about not finding
the `show` action. That's not very useful though, so let's add the
-`show` action before proceeding.
-Open the file `config/routes.rb` and add this line.
-
-```ruby
-resources :posts
-```
-
-If you run `rake routes` in your terminal, several lines will be shown regarding posts, including this:
-
-```
-post GET /posts/:id(.:format) posts#show
-```
+`show` action before proceeding. The show action is matched by this route in the `rake routes` output:
The special syntax `:id` tells rails that this route expects an `:id`
parameter, which in our case will be the id of the post.
@@ -599,8 +588,9 @@ end
```
A couple of things to note. We use `Post.find` to find the post we're
-interested in. We also use an instance variable (prefixed by `@`) to
-hold a reference to the post object. We do this because Rails will pass all instance
+interested in, passing in `params[:id]` to get the `:id` parameter from the
+request. We also use an instance variable (prefixed by `@`) to hold a
+reference to the post object. We do this because Rails will pass all instance
variables to the view.
Now, create a new file `app/views/posts/show.html.erb` with the following