SHOW:
|
|
- or go back to the newest paste.
| 1 | - | def edit #index |
| 1 | + | <h1>Edit Post</h1> |
| 2 | - | @post = Post.find(params[:id]) |
| 2 | + | <%= form_for @post do |f| %> |
| 3 | - | end |
| 3 | + | <p> |
| 4 | - | |
| 4 | + | <%= f.label :title %><br /> |
| 5 | - | def update |
| 5 | + | <%= f.text_field :title %> |
| 6 | - | @post = Post.find(params[:id]) |
| 6 | + | </p> |
| 7 | - | |
| 7 | + | <p> |
| 8 | - | if @post.update_attributes(params[:post]) |
| 8 | + | <%= f.label :content %><br /> |
| 9 | - | redirect_to posts_path, :notice => "Post has been updated." |
| 9 | + | <%= f.text_area :content %> |
| 10 | - | else |
| 10 | + | </p> |
| 11 | - | render "edit" |
| 11 | + | <p> |
| 12 | - | end |
| 12 | + | <%= f.submit "Update" %> |
| 13 | - | end |
| 13 | + | </p> |
| 14 | <% end %> |