# Help with form

**URL:** <https://www.ruby-forum.com/t/help-with-form/97020>\
**Category:** Rails\
**Created:** [December 9, 2005, 5:34pm UTC](https://www.ruby-forum.com/t/help-with-form/97020 "2005-12-09T17:34:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![farocco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@farocco](https://www.ruby-forum.com/u/farocco)\
**Post date:** [December 9, 2005, 5:34pm UTC](https://www.ruby-forum.com/t/help-with-form/97020/1 "2005-12-09T17:34:21Z")

</div>

Hello,

I am getting a application error(rails) when I click the edit button.  
What am I doing wrong?  
Thanks  
Frank

\<%= start\_form\_tag :action =\> ‘update’, :id =\> @receipt %\>

| **Patient Information** | &nbsp; |
| Last Name | \<%= text\_field("receipt","LAST", "size" =\> 50) %\> |
| \<%= submit\_tag 'Edit' %\> |

\<%= end\_form\_tag %\>

def update  
@receipt = Receipt.find(params[:id])  
if @receipt.update\_attributes(params[:receipt])  
flash[:notice] = ‘Receipt was successfully updated.’  
redirect\_to :action =\> ‘show’, :id =\> @receipt  
else  
render :action =\> ‘edit’  
end  
end

---

<div class="post-metadata">

**Author:** ![farocco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@farocco](https://www.ruby-forum.com/u/farocco)\
**Post date:** [December 9, 2005, 7:39pm UTC](https://www.ruby-forum.com/t/help-with-form/97020/2 "2005-12-09T19:39:54Z")

</div>

Can someone pleas ehelp me with this?

Thanks

Frank  
----- Original Message -----  
From: Frank  
To: removed\_email\_address@domain.invalid  
Sent: Friday, December 09, 2005 11:11 AM  
Subject: [Rails] help with form

Hello,

I am getting a application error(rails) when I click the edit button.  
What am I doing wrong?  
Thanks  
Frank

\<%= start\_form\_tag :action =\> ‘update’, :id =\> @receipt %\>

```
<tr><td><%= submit_tag 'Edit' %></td></tr>
</table>

```

\<%= end\_form\_tag %\>

def update  
@receipt = Receipt.find(params[:id])  
if @receipt.update\_attributes(params[:receipt])  
flash[:notice] = ‘Receipt was successfully updated.’  
redirect\_to :action =\> ‘show’, :id =\> @receipt  
else  
render :action =\> ‘edit’  
end  
end

* * *

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

| **Patient Information** | &nbsp; |
| Last Name | \<%= text\_field("receipt","LAST", "size" =\> 50) %\> |

---

<div class="post-metadata">

**Author:** ![farocco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@farocco](https://www.ruby-forum.com/u/farocco)\
**Post date:** [December 9, 2005, 7:56pm UTC](https://www.ruby-forum.com/t/help-with-form/97020/3 "2005-12-09T19:56:45Z")

</div>

Frank wrote:

> def update  
> @receipt = Receipt.find(params[:id])  
> if @receipt.update\_attributes(params[:receipt])  
> flash[:notice] = ‘Receipt was successfully updated.’  
> redirect\_to :action =\> ‘show’, :id =\> @receipt

I’ve taken a look at your code twice, and this is the only thing that  
jumped out  
at me…

You’re redirect\_to action is trying to assign the entire Receipt record  
as the  
:id. Try changing it to “:id =\> @receipt.id”.

-Brian

---

<div class="post-metadata">

**Author:** ![farocco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@farocco](https://www.ruby-forum.com/u/farocco)\
**Post date:** [December 12, 2005, 12:00am UTC](https://www.ruby-forum.com/t/help-with-form/97020/4 "2005-12-12T00:00:08Z")

</div>

Hi Brian,

I regenerated my app and it seems to work on my mac.  
I am going to try it on my windows pc at work on Monday.

Regards,  
Frank

---

<div class="post-metadata">

**Author:** ![farocco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f08c70/32.png) [@farocco](https://www.ruby-forum.com/u/farocco)\
**Post date:** [December 11, 2005, 11:06pm UTC](https://www.ruby-forum.com/t/help-with-form/97020/5 "2005-12-11T23:06:22Z")

</div>

Hi Frank,

I’m just curious. Do you get anything returned with  
@receipt = Receipt.find(params[:id])

On the initial load of the form the params[:id] will be present, but is  
it  
present when the form is submitted to the update action?

Cheers
