diff options
author | Amparo Luna + Guillermo Iguaran <amparo.m.luna@gmail.com+guilleiguaran@gmail.com> | 2013-01-02 16:40:48 -0500 |
---|---|---|
committer | Amparo Luna + Guillermo Iguaran <amparo.m.luna@gmail.com+guilleiguaran@gmail.com> | 2013-01-03 12:04:25 -0500 |
commit | 03ac174f2d35c92ffefd35a7f69369eb5117d8a7 (patch) | |
tree | 3c9a6c226b04f11a92d9d57cf9017e5ad57e31ea /guides/source/getting_started.md | |
parent | 1bb020063c1bad6cc6a2ad7a4635bfc31a308f65 (diff) | |
download | rails-03ac174f2d35c92ffefd35a7f69369eb5117d8a7.tar.gz rails-03ac174f2d35c92ffefd35a7f69369eb5117d8a7.tar.bz2 rails-03ac174f2d35c92ffefd35a7f69369eb5117d8a7.zip |
Change guides to use update instead of update_attributes
Diffstat (limited to 'guides/source/getting_started.md')
-rw-r--r-- | guides/source/getting_started.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 02ec024e5b..aa841d5867 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -882,7 +882,7 @@ And then create the `update` action in `app/controllers/posts_controller.rb`: def update @post = Post.find(params[:id]) - if @post.update_attributes(params[:post]) + if @post.update(params[:post]) redirect_to action: :show, id: @post.id else render 'edit' @@ -890,13 +890,13 @@ def update end ``` -The new method, `update_attributes`, is used when you want to update a record +The new method, `update`, is used when you want to update a record that already exists, and it accepts a hash containing the attributes that you want to update. As before, if there was an error updating the post we want to show the form back to the user. -TIP: You don't need to pass all attributes to `update_attributes`. For -example, if you'd call `@post.update_attributes(title: 'A new title')` +TIP: You don't need to pass all attributes to `update`. For +example, if you'd call `@post.update(title: 'A new title')` Rails would only update the `title` attribute, leaving all other attributes untouched. |