eriklane
2008-Mar-16 15:26 UTC
logic problem: writing to a second table from within the active controller
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---