you basically have 2 choices
@claim = Claim.find(params[:id]) # load record
@claim.update_attributes(params[:attributes]) #update specific
attributes and save record
or
@claim = Claim.update(params[:id], params[:attributes])
both of which basically do the same thing.
ActiveRecord works at the row level, meaning, even if you just want to
change a few fields, the whole record still gets saved, not just the
fields you changed.
if you need your AR objects to be aware of changes possibly made by
others, look into the following plugins:
acts_as_versioned
acts_as_modified
also, there is another plugin, acts_as_changed, which appears to only
update those attributes that have changed, and not the entire record.
Chris
On 9/5/06, Jeremy Cowgar <jeremy-gpWmyxsr1AXQT0dZR+AlfA@public.gmane.org>
wrote:>
> I have a claim model representing a medical claim. It has some 130
> fields. In one screen, the only option is to update 3 of those
> fields, status, discount_amount, payout_amount. It seems that if I:
>
> @claim=Claim.find(params[:id], :select =>
> ''id,status,discount_amount,payout_amount'')
> @claim.update_attributes(params[:claim])
>
> that it will begin to complain field by field of missing values that
> I did not select.
>
> Do I have to select * in order to update only three attributes? I
> could write a method that updates those three via SQL, but what then
> when I move to a general update screen that updates around 40 of
> those attributes?
>
> Thanks!
>
> Jeremy
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---