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
<title> ''Edit Person''</title>
<%form_for(:person,@person,:url=>{:action=>''update''},:html=>{:method=>''put''},
do |p|%>
<u><span class="style1">Create or Search an
Individual</span><span
class="style2">l</span></u>
<%=submit_tag "Update
Person"%>
<table width="100%" border="9">
<td width="4%"><input name="category"
type="checkbox" id="category"
value="1" /></td>
<td width="30%"><strong>Category:
<%=p.select("category_id",Category.find(:all).collect{|cat|[cat.category_name,cat.id]},{:prompt=>"-Select
a category"})%>
</strong></td>
</tr>
<tr>
<td><input name="title" type="checkbox"
id="title" value="1" /></td>
<td><strong>Title:<%=p.text_field("title")%></strong></td>
<td><input name="title_other" type="checkbox"
id="title_other"
value="1" /></td>
<td><strong>Title Other: <%=p.text_field
"title_other"%>
</strong></td>
...........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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---