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 %> <table> <tr><td><b>Patient Information</b></td><td> </td></tr> <tr><td>Last Name</td><td><%= text_field("receipt","LAST", "size" => 50) %></td></tr> <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 Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Can someone pleas ehelp me with this? Thanks Frank ----- Original Message ----- From: Frank To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org 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 %> <table> <tr><td><b>Patient Information</b></td><td> </td></tr> <tr><td>Last Name</td><td><%= text_field("receipt","LAST", "size" => 50) %></td></tr> <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 Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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 => @receiptI''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
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 On 12/10/05, Brian V. Hughes <brianvh-ilmOVS5JQ6Xj7r8U7pfrKh2eb7JE58TQ@public.gmane.org> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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 On Dec 11, 2005, at 5:04 PM, Liquid wrote:> 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 > > On 12/10/05, Brian V. Hughes <brianvh-ilmOVS5JQ6Xj7r8U7pfrKh2eb7JE58TQ@public.gmane.org> wrote: > 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 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails