# Why I can't update data, but I can insert data into new model

**URL:** <https://www.ruby-forum.com/t/why-i-cant-update-data-but-i-can-insert-data-into-new-model/117723>\
**Category:** Rails\
**Created:** [October 19, 2007, 6:56pm UTC](https://www.ruby-forum.com/t/why-i-cant-update-data-but-i-can-insert-data-into-new-model/117723 "2007-10-19T18:56:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![OnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/51bf81/32.png) [@OnRails](https://www.ruby-forum.com/u/OnRails)\
**Post date:** [October 19, 2007, 6:56pm UTC](https://www.ruby-forum.com/t/why-i-cant-update-data-but-i-can-insert-data-into-new-model/117723/1 "2007-10-19T18:56:03Z")

</div>

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!!
