Skip to content
Browse files

Add author_name field to post_params to the engines docs

  • Loading branch information...
1 parent 4f5f59a commit 9d39577bd9509b5168f92269a0482e2fd0615093 @cr0t cr0t committed Aug 10, 2013
Showing with 8 additions and 0 deletions.
  1. +8 −0 guides/source/engines.md
View
8 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.

0 comments on commit 9d39577

Please sign in to comment.
Something went wrong with that request. Please try again.