Displaying 1 result from an estimated 1 matches for "is_contact".
Did you mean:
gim_contact
2006 Jan 09
0
Saving or updating multiple models
...ctiveRecord::Base
# several validations
end
and the following controller_code:
class WorkersController < ApplicationController
def create
@worker = Worker.new(params[:worker])
@worker.person = Person.new(params[:person])
@worker.user = User.new(params[:user]) if @worker.is_contact
if @worker.save
# success
else
# failure
end
end
end
The problem as far as I can see here is, that the @worker model is
tried to be saved, without saving the children first.
Another thing is, when I do things like:
@worker.person.save
@worker.save
t...