# Update record problem

**URL:** <https://www.ruby-forum.com/t/update-record-problem/173551>\
**Category:** Rails\
**Created:** [August 11, 2009, 11:23am UTC](https://www.ruby-forum.com/t/update-record-problem/173551 "2009-08-11T11:23:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 11:23am UTC](https://www.ruby-forum.com/t/update-record-problem/173551/1 "2009-08-11T11:23:31Z")

</div>

i have admins controller and in this i want to two times update one for  
admin and other for cateupdate both methods are different.

def catedit  
@pro\_categorie = ProCategorie.find(params[:id])  
end

def cateupdate  
@pro\_categorie = ProCategorie.find(params[:id])

```
respond_to do |format|
  if @pro_categories.update_attributes(params[:pro_categorie])
    flash[:notice] = 'Product category was successfully updated.'
    #format.html { redirect_to(@admin) }
format.html { redirect_to(admins_url) }
    format.xml { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml { render :xml => @pro_categorie.errors, :status =>

```

:unprocessable\_entity }  
end  
end  
end

==================\>\>\> cateedit.html.erb

### Product category
 \<% form\_for(@pro\_categorie,:url=\>{:controller =\> 'admins', :action =\> 'cateupdate'}) do |f| %\> \<%= f.error\_messages %\> 

| Category Name : | \<%= f.text\_field :pcate\_name %\> |
| Category Desc : | \<%= f.text\_field :pcate\_desc %\> |
| \<%= f.submit 'Update' %\>&nbsp;&nbsp;&nbsp;&nbsp;\<%= link\_to 'Back', admins\_path %\> |

 \<%end%\>

i got error  
ActiveRecord::RecordNotFound in AdminsController#update

Couldn’t find Admin with ID=cateupdate

i have pro\_categories table edit file display record but when i press  
update i give me above error

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 11:37am UTC](https://www.ruby-forum.com/t/update-record-problem/173551/2 "2009-08-11T11:37:43Z")

</div>

On Aug 11, 10:23 am, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i got error  
> ActiveRecord::RecordNotFound in AdminsController#update
> 
> Couldn’t find Admin with ID=cateupdate
> 
> i have pro\_categories table edit file display record but when i press  
> update i give me above error

in a restful world when you add actions you need to add them to your  
routes file (see the :member and :collection options to map.resources)

Fred

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 2:53pm UTC](https://www.ruby-forum.com/t/update-record-problem/173551/3 "2009-08-11T14:53:59Z")

</div>

Wap A. wrote:

> Frederick C. wrote:
> 
> > On Aug 11, 10:23ï¿½am, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > wrote:
> > 
> > > i got error  
> > > ï¿½ActiveRecord::RecordNotFound in AdminsController#update
> > > 
> > > Couldn’t find Admin with ID=cateupdate
> > > 
> > > i have pro\_categories table edit file display record but when i press  
> > > update i give me above error
> > 
> > in a restful world when you add actions you need to add them to your  
> > routes file (see the :member and :collection options to map.resources)
> > 
> > Fred
> 
> i am not understand your suggestion.

i have to fix my problem like this

### Product category
 \<% form\_for( :pro\_categorie, :url =\> {:action =\> 'updatecate',:id =\> @pro\_categorie.id}) do |f| %\> \<%= f.error\_messages %\> 

| Category Name : | \<%= f.text\_field :pcate\_name %\> |
| Category Desc : | \<%= f.text\_field :pcate\_desc %\> |
| \<%= f.submit 'Update' %\>&nbsp;&nbsp;&nbsp;&nbsp;\<%= link\_to 'Back', admins\_path %\> |

 \<%end%\>

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 11:41am UTC](https://www.ruby-forum.com/t/update-record-problem/173551/4 "2009-08-11T11:41:58Z")

</div>

Frederick C. wrote:

> On Aug 11, 10:23ï¿½am, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > i got error  
> > ï¿½ActiveRecord::RecordNotFound in AdminsController#update
> > 
> > Couldn’t find Admin with ID=cateupdate
> > 
> > i have pro\_categories table edit file display record but when i press  
> > update i give me above error
> 
> in a restful world when you add actions you need to add them to your  
> routes file (see the :member and :collection options to map.resources)
> 
> Fred

i am not understand your suggestion.
