Help with form


#1

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  
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


#2

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

Patient Information  
Last Name <%= text_field("receipt","LAST", "size" => 50) %>

#3

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


#4

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


#5

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