# Logic problem: writing to a second table from within the active controller

**URL:** <https://www.ruby-forum.com/t/logic-problem-writing-to-a-second-table-from-within-the-active-controller/132077>\
**Category:** Rails\
**Created:** [March 16, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/logic-problem-writing-to-a-second-table-from-within-the-active-controller/132077 "2008-03-16T16:27:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eriklane](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/977dab/32.png) [@eriklane](https://www.ruby-forum.com/u/eriklane)\
**Post date:** [March 16, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/logic-problem-writing-to-a-second-table-from-within-the-active-controller/132077/1 "2008-03-16T16:27:12Z")

</div>

Hi all,

Just not sure how to do this in RoR.

Scenario:  
Parents sign in to register their kids, child list populated based on  
same last name (based on an imported excel file). Parents click  
register next to childs name…process\_registration action  
called…code below…

1. want to create the new registration (works fine)
2. want to create the relationship between the parent and child in  
another model/table so I don’t have to guess the relationship in the  
future. Relationship model is created. 3 columns (id1(int),  
id2(int), type(string))

I’m getting the following error:  
uninitialized constant RegistrationController::Relationship

So, how do I make this Relationship table available for writing???

def process\_registration

```
@registration = Registration.new(params[:registration])
@relationship = Relationship.new( id1 => 'params[:registration]

```

[:parent\_id]’, id2 =\> ‘params[:registration][:child\_id]’, type =\>  
‘parentchild’ )

```
respond_to do |format| format
  if @registration.save
    flash[:notice] = "Player was successfully registered."
    format.html { redirect_to( :controller =>

```

‘registration’, :action =\> ‘springtraining’) }  
format.xml { head :ok }  
else  
format.html { render :action =\> “springtraining” }  
format.xml { render :xml =\> @registration.errors, :status  
=\> :unprocessable\_entity }  
end  
end  
end
