diff options
author | Oscar Del Ben <info@oscardelben.com> | 2012-04-24 14:21:07 +0200 |
---|---|---|
committer | Oscar Del Ben <info@oscardelben.com> | 2012-04-24 14:21:07 +0200 |
commit | f0de7172a6e1a52bf122578954d805a36a488d27 (patch) | |
tree | e5d5a1899f1d3d9224cc0245795c55dc8f62349f /guides/code/getting_started/app/controllers | |
parent | 5acb345a86584e3c9c4b5a81c4499c767393c89a (diff) | |
download | rails-f0de7172a6e1a52bf122578954d805a36a488d27.tar.gz rails-f0de7172a6e1a52bf122578954d805a36a488d27.tar.bz2 rails-f0de7172a6e1a52bf122578954d805a36a488d27.zip |
Add update post section to getting started guide
Diffstat (limited to 'guides/code/getting_started/app/controllers')
-rw-r--r-- | guides/code/getting_started/app/controllers/posts_controller.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb index 947cd2a767..fc71e9b4e8 100644 --- a/guides/code/getting_started/app/controllers/posts_controller.rb +++ b/guides/code/getting_started/app/controllers/posts_controller.rb @@ -21,4 +21,18 @@ class PostsController < ApplicationController render 'new' end end + + def edit + @post = Post.find(params[:id]) + end + + def update + @post = Post.find(params[:id]) + + if @post.update_attributes(params[:post]) + redirect_to :action => :show, :id => @post.id + else + render 'edit' + end + end end |