I hope I'm explaining this correctly.  Be gentle.  Noob here.  :)

Ideas on how to solve this?  Kind of a chicken or the egg scenario.
Check out this update function in my controller:

  def update
    @snowplow_registration = SnowplowRegistration.find(params[:id])
    @customer = Customer.find(@snowplow_registration.customer)

    SnowplowRegistration.transaction do
      @snowplow_registration.update_attributes!(params[:snowplow_registration])
      @customer.update_attributes!(params[:customer])
      flash[:notice] = 'Snow Plow Registration was successfully
updated.'
      redirect_to(@snowplow_registration)
    end

  rescue ActiveRecord::RecordInvalid => e
    @customer.valid?
    render :action => "edit"
  end

When the transaction starts, if validation fails on the
@snowplow_registration, it doesn't check the validation on my @customer
for the fields that were updated.  Validation for both works properly
when testing separate... but @customer returns to the edit page without
passing the changed (params[:customer]) because the failure in the
transaction happened before I can call
@customer.update_attributes!(params[:customer]).  Is there a way to
update the model in memory before updating the database?

Thank you for looking.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to