# Insert record in table error

**URL:** <https://www.ruby-forum.com/t/insert-record-in-table-error/173501>\
**Category:** Rails\
**Created:** [August 10, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501 "2009-08-10T16:34:52Z")\
**Posts on this page:** 6\
**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 10, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501/1 "2009-08-10T16:34:52Z")

</div>

i have cateadd.html.erb file in admins folder and i want call admins  
controller and define method like this

```
       def cateadd
@pro_categorie = ProCategorie.new
respond_to do |formate|
format.html # new.html.erb
           format.xml { render :xml => @pro_categorie }
         end

```

end

pro\_categories is table name i want to insert record in this table  
but bad luck i can not do it

---

<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 10, 2009, 5:14pm UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501/2 "2009-08-10T17:14:26Z")

</div>

Wap A. wrote:

> i have cateadd.html.erb file in admins folder and i want call admins  
> controller and define method like this
> 
> ```
> def cateadd
> @pro_categorie = ProCategorie.new
> respond_to do |formate|
> format.html # new.html.erb
> format.xml { render :xml => @pro_categorie }
> end
> 
> ```
> 
> end
> 
> pro\_categories is table name i want to insert record in this table  
> but bad luck i can not do it

I believe rails pluralization rules may be getting confused here… try  
renaming your model to “ProCategory” or add:

class ProCategorie  
set\_table\_name “pro\_categories”  
end

hth  
ilan

---

<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 10, 2009, 5:55pm UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501/3 "2009-08-10T17:55:53Z")

</div>

On Aug 10, 3:34 pm, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i have cateadd.html.erb file in admins folder and i want call admins  
> controller and define method like this
> 
> ```
> def cateadd
> @pro_categorie = ProCategorie.new
> respond_to do |formate|
> format.html # new.html.erb
> format.xml { render :xml => @pro_categorie }
> end
> 
> ```

You’ve got a typo here - formate/format

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, 9:51am UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501/4 "2009-08-11T09:51:47Z")

</div>

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

> \<% form\_for(@pro\_categorie) do |f| %\>

Have you added map.resources :pro\_categories in your routes.rb file ?  
THat’s the price you must pay to be able to use this short form. If  
you have then the most likely reason is rails getting confused about  
the pluralization

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, 11:05am UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501/5 "2009-08-11T11:05:42Z")

</div>

Frederick C. wrote:

> On Aug 11, 6:34ï¿½am, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > ï¿½ ï¿½\<% form\_for(@pro\_categorie) do |f| %\>
> 
> Have you added map.resources :pro\_categories in your routes.rb file ?  
> THat’s the price you must pay to be able to use this short form. If  
> you have then the most likely reason is rails getting confused about  
> the pluralization
> 
> Fred

thanks for give me right direction

---

<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, 7:34am UTC](https://www.ruby-forum.com/t/insert-record-in-table-error/173501/6 "2009-08-11T07:34:56Z")

</div>

Frederick C. wrote:

> On Aug 10, 3:34ï¿½pm, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > i have cateadd.html.erb file in admins folder and i want call admins  
> > controller and define method like this
> > 
> > ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½def cateadd  
> > ï¿½ ï¿½ @pro\_categorie = ProCategorie.new  
> > ï¿½ ï¿½ respond\_to do |formate|  
> > ï¿½ ï¿½ format.html # new.html.erb  
> > ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½format.xml ï¿½{ render :xml =\> @pro\_categorie }  
> > ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½ ï¿½end
> 
> You’ve got a typo here - formate/format
> 
> Fred

thanks dear is it ok but when put on @pro\_categorie in cateadd.html.erb  
is below

### Add product category

\<% form\_for(@pro\_categorie) do |f| %\>  
\<%= f.error\_messages %\>

| Category Name : | \<%= f.text\_field :pcate\_name %\> |
| Category Description : | \<%= f.text\_field :pcate\_desc %\> |

 \<%end%\>

i got error  
Showing app/views/admins/cateadd.html.erb where line #5 raised:

undefined method `pro\_categories\_path’ for #ActionView::Base:0x4839358
