aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Kuznetsov <kuznecov.sg@gmail.com>2013-08-10 14:58:24 +0400
committerSergey Kuznetsov <kuznecov.sg@gmail.com>2013-08-10 14:58:24 +0400
commit9d39577bd9509b5168f92269a0482e2fd0615093 (patch)
treec46f2af49dc6b39f788a082e6869e29ffbe6e23d
parent4f5f59a492bd32afa476ac6b51ca5295b70fe246 (diff)
downloadrails-9d39577bd9509b5168f92269a0482e2fd0615093.tar.gz
rails-9d39577bd9509b5168f92269a0482e2fd0615093.tar.bz2
rails-9d39577bd9509b5168f92269a0482e2fd0615093.zip
Add author_name field to post_params to the engines docs
-rw-r--r--guides/source/engines.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/guides/source/engines.md b/guides/source/engines.md
index a77be917a2..9106b6382d 100644
--- a/guides/source/engines.md
+++ b/guides/source/engines.md
@@ -525,6 +525,14 @@ First, the `author_name` text field needs to be added to the `app/views/blorgh/p
</div>
```
+Next, we need to update our `Blorgh::PostController#post_params` method to permit the new form parameter:
+
+```ruby
+def post_params
+ params.require(:post).permit(:title, :text, :author_name)
+end
+```
+
The `Blorgh::Post` model should then have some code to convert the `author_name` field into an actual `User` object and associate it as that post's `author` before the post is saved. It will also need to have an `attr_accessor` setup for this field so that the setter and getter methods are defined for it.
To do all this, you'll need to add the `attr_accessor` for `author_name`, the association for the author and the `before_save` call into `app/models/blorgh/post.rb`. The `author` association will be hard-coded to the `User` class for the time being.