# Edit a form

**URL:** <https://www.ruby-forum.com/t/edit-a-form/124800>\
**Category:** Rails\
**Created:** [January 2, 2008, 7:12pm UTC](https://www.ruby-forum.com/t/edit-a-form/124800 "2008-01-02T19:12:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [January 2, 2008, 7:12pm UTC](https://www.ruby-forum.com/t/edit-a-form/124800/1 "2008-01-02T19:12:54Z")

</div>

Hello,  
I have two functions edit and update in my controller.  
edit is used to display the person’s details and when the update button  
is clicked the update function should be executed.  
The problem is after clicking the update button I get the error message  
ID not found. I think the problem is that the form\_for syntax i am using  
is incorrect for editing. Please help me corect the problem

Here is the code:

The rhtml file that displays the form to be edited is as

#edit.rhtml

 'Edit Person' \<%form\_for(:person,@person,:url=\>{:action=\>'update'},:html=\>{:method=\>'put'}, do |p|%\> Create or Search an Individuall \<%=submit\_tag "Update Person"%\>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...........and the rest fields continues ....

The controller is as

#person\_controller.rb  
@person = Person.find(params[:id])  
render :action=\>‘edit’  
end

def update

@person = Person.find(params[:id])  
if @person.update\_attributes(params[:person])  
flash[:notice]= “Successfully Updated person.”  
render :action=\>‘edit’  
end  
end

Thank you.  
Regards,  
Anks

| | **Category: \<%=p.select("category\_id",Category.find(:all).collect{|cat|[cat.category\_name,cat.id]},{:prompt=\>"-Select a category"})%\>** |
| | **Title:\<%=p.text\_field("title")%\>** | | **Title Other: \<%=p.text\_field "title\_other"%\>** |
