I wanted to followup on this with a solution I found. While reading
the Agile Web Development book, I found that it referenced updating
single attributes with the "find_by_sql" in where you will only
update columns that you select. Since I have a :through association,
I do not think that method was available to me.
So in order to update a single attribute to a model object, I limited
the :select option of the standard find method. So it ended up
looking something like this. I used fully qualified column names in
the select statement. I found this worked well.
obj = User.bla.find(params[:id], :select => "bla.id,
bla.title")
obj_title = params[:title]
obj.title = obj_title
if obj.save!
# etc...
end
On Apr 21, 2006, at 5:37 PM, Fernanda Aispuro wrote:
> Hi,
>
>
>
> I was reading the messages at http://wrath.rubyonrails.org/
> pipermail/rails/2005-December/006969.html, Subject: [Rails]
> update_attribute send updates every field, why?
>
> Well, I am having the same problem, and I do have a binary column
> where I am storing files. Also, I am calling a web service so I can
> send the binary file (only this column) to the SQL Server database,
> making a call again would be kind of expensive.
>
> Is there a way to update only one column instead of all of them?
>
> Thanks you,
> Fernanda
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060508/f220beb9/attachment.html