From: Tim McIntyre Date: 2007-10-20T05:58:09+09:00 Subject: Re: why I can't update data, but I can insert data into new mode --Apple-Mail-3--228085423 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed File may be an unfortunate name for your ActiveRecord class since it's also a built in ruby class. when you do find_by_id (same as just find BTW) your getting your ActiveRecord class instance and when you do File.new your getting an instance of the built in ruby class which does not contain a "name=" method that's what I'm guessing anyway... checkout the RoR group;-) Tim On Oct 19, 2007, at 1:40 PM, OnRails Ruby wrote: > why I can't update data, but I can insert data into new model. > like this: > if File.find_by_id(id) > file=File.find_by_id(id) > else > file=File.new > > file.name=name > file.save > > there is a problem, when there don't find id, there is no problem, But > when find id, update the field, > there is Error, there said: undefined method 'name=' > why? who can help me? Thanks!! > -- > Posted via http://www.ruby-forum.com/. > Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind. - Dr. Seuss --Apple-Mail-3--228085423--