Displaying 1 result from an estimated 1 matches for "controller_code".
2006 Jan 09
0
Saving or updating multiple models
...d::Base
belongs_to :person
belongs_to :user
validates_presence_of :person_id
end
class Person < ActiveRecord::Base
has_many :workers
end
class Client < ActiveRecord::Base
has_many :workers
end
class User < ActiveRecord::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
# fa...