Edit a form

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"%>      ...........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"%>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs