# Understanding Rails Controllers/Models

**URL:** <https://www.ruby-forum.com/t/understanding-rails-controllers-models/195163>\
**Category:** Rails\
**Created:** [September 17, 2010, 11:28pm UTC](https://www.ruby-forum.com/t/understanding-rails-controllers-models/195163 "2010-09-17T23:28:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [September 17, 2010, 11:28pm UTC](https://www.ruby-forum.com/t/understanding-rails-controllers-models/195163/1 "2010-09-17T23:28:25Z")

</div>

Hello, Rails newbie… trying to understand the right way to do  
things…

In my app users can create a Book ( I have that working)

What I want to happen is when a user creates a book, a record is added  
to the BookCharacters Table, something like (id, book.id, user.id,  
characterdescription.string.)

When the book is created, the user who created it should automatically  
be added as the first BookCharacter. After than the user can then  
manually add/edit as many BookCharacters as they want. But initially I  
want them added automatically by default.

So in my Book controller I have:  
def create  
@book = Book.new(params[:book])  
respond\_to do |format|  
if @book.save  
…

With Rails, is it the practice to add that kind of logic after the  
book is saved? Something like  
Book.create( :creator =\> current\_user.id)

Thanks!

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [September 17, 2010, 11:29pm UTC](https://www.ruby-forum.com/t/understanding-rails-controllers-models/195163/2 "2010-09-17T23:29:00Z")

</div>

Forgot to add. I’m using Rails 3. thxs
