Browse files

[getting started] Don't define resources :posts a second time + clari…

…fy messaging around 'Showing Posts' section
  • Loading branch information...
1 parent 97d5ccf commit dba4c6fe539c24ec1beb106e34f37f3cd0632022 @radar radar committed Aug 16, 2013
Showing with 4 additions and 14 deletions.
  1. +4 −14 guides/source/getting_started.md
View
18 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

0 comments on commit dba4c6f

Please sign in to comment.