# Database error

**URL:** <https://www.ruby-forum.com/t/database-error/187363>\
**Category:** Rails\
**Created:** [April 22, 2010, 6:25am UTC](https://www.ruby-forum.com/t/database-error/187363 "2010-04-22T06:25:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smit\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@smit\_shah](https://www.ruby-forum.com/u/smit_shah)\
**Post date:** [April 22, 2010, 6:25am UTC](https://www.ruby-forum.com/t/database-error/187363/1 "2010-04-22T06:25:57Z")

</div>

Hi All,

I am trying to save my form data in to table. I am able to add the data  
successfully but it creates the 2 record for the single time of form  
submission.

Let me explain in detail. My flow is like following:

First the user fills the form. When it submits the form, create method  
will called and after completion of that it redirects to show page of  
created user.

In browser it works just like I said. But, in back-end(in log), it  
creates one record than redirects to the show page, than once again it  
hits the create def and insert the same data in to table and again  
redirects to show page.

I am using rails 2.3.5 and ruby 1.8.6

Any idea???

---

<div class="post-metadata">

**Author:** ![smit\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@smit\_shah](https://www.ruby-forum.com/u/smit_shah)\
**Post date:** [April 22, 2010, 7:10am UTC](https://www.ruby-forum.com/t/database-error/187363/2 "2010-04-22T07:10:24Z")

</div>

Smit S. wrote:

> Hi All,
> 
> I am trying to save my form data in to table. I am able to add the data  
> successfully but it creates the 2 record for the single time of form  
> submission.
> 
> Let me explain in detail. My flow is like following:
> 
> First the user fills the form. When it submits the form, create method  
> will called and after completion of that it redirects to show page of  
> created user.
> 
> In browser it works just like I said. But, in back-end(in log), it  
> creates one record than redirects to the show page, than once again it  
> hits the create def and insert the same data in to table and again  
> redirects to show page.
> 
> I am using rails 2.3.5 and ruby 1.8.6
> 
> Any idea???

Your create method is getting called twice. A look at code would help in  
resolving the issue.

Anubhaw
