I''m working through the four days on rails tutorial, but I''m stumped. On p. 11-12, you create a custom rhtml page for the edit view. When I submit the changes, I get an error "Couldn''t find Category without an ID". But the ID is being submitted: "Parameters: {"category"=>{"category"=>"dogs", "id"=>"3"}}" Am I missing something, or is this a bug in the tutorial? I''ve found several bugs so far, but so far I''ve been able to figure out the solutions. This one has me stumped, though it might just be that I''m exhausted. BTW, can someone update the version of the tutorial on the RoR page to point to the latest version? The version there is 1.7 & the current version is 1.9. I suspect that at least some of the problems that I''ve found have been fixed by now. Here''s the code from my new edit page: <h1>Rename Category</h1> <form action="/todo/public/categories/update" method="post"> <%= error_messages_for ''category'' %> <%= hidden_field "category", "id" %> <table border=0> <tr> <td><b>Category:</b></td> <td><%= text_field "category", "category", "size" => 20, "maxlength" => 20 %></td> </tr> </table> <hr> <input type="submit", value="Update"> </form> <%= link_to ''Cancel'', :action => ''list'' %> (I hope this question hasn''t been answered previously... Gmane''s search feature doesn''t seem to be working)
On 28/04/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m working through the four days on rails tutorial, but I''m stumped. > On p. 11-12, you create a custom rhtml page for the edit view. When I > submit the changes, I get an error "Couldn''t find Category without an > ID". But the ID is being submitted: "Parameters: > {"category"=>{"category"=>"dogs", "id"=>"3"}}" > > Am I missing something, or is this a bug in the tutorial? I''ve found > several bugs so far, but so far I''ve been able to figure out the > solutions. This one has me stumped, though it might just be that I''m > exhausted. > > BTW, can someone update the version of the tutorial on the RoR page to > point to the latest version? The version there is 1.7 & the current > version is 1.9. I suspect that at least some of the problems that I''ve > found have been fixed by now. > > Here''s the code from my new edit page: > > <h1>Rename Category</h1> > > <form action="/todo/public/categories/update" method="post"> > <%= error_messages_for ''category'' %> > <%= hidden_field "category", "id" %> > > <table border=0> > <tr> > <td><b>Category:</b></td> > <td><%= text_field "category", "category", "size" => 20, > "maxlength" => 20 %></td> > </tr> > </table> > <hr> > <input type="submit", value="Update"> > </form> > > <%= link_to ''Cancel'', :action => ''list'' %> > > (I hope this question hasn''t been answered previously... Gmane''s > search feature doesn''t seem to be working)Post the update action code, that''s where the problem is. -- Phillip Hutchings http://www.sitharus.com/ sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org
Here''s the update code: def update @category = Category.find(@params[:id]) if @category.update_attributes(@params[:category]) flash[''notice''] = ''Category was successfully updated.'' redirect_to :action => ''list'' else render_action ''edit'' end end I believe that that is the automatically generated code (I may have changed the redirect_to bit.) On 4/27/05, Phillip Hutchings <sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 28/04/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m working through the four days on rails tutorial, but I''m stumped. > > On p. 11-12, you create a custom rhtml page for the edit view. When I > > submit the changes, I get an error "Couldn''t find Category without an > > ID". But the ID is being submitted: "Parameters: > > {"category"=>{"category"=>"dogs", "id"=>"3"}}" > > > > Am I missing something, or is this a bug in the tutorial? I''ve found > > several bugs so far, but so far I''ve been able to figure out the > > solutions. This one has me stumped, though it might just be that I''m > > exhausted. > > > > BTW, can someone update the version of the tutorial on the RoR page to > > point to the latest version? The version there is 1.7 & the current > > version is 1.9. I suspect that at least some of the problems that I''ve > > found have been fixed by now. > > > > Here''s the code from my new edit page: > > > > <h1>Rename Category</h1> > > > > <form action="/todo/public/categories/update" method="post"> > > <%= error_messages_for ''category'' %> > > <%= hidden_field "category", "id" %> > > > > <table border=0> > > <tr> > > <td><b>Category:</b></td> > > <td><%= text_field "category", "category", "size" => 20, > > "maxlength" => 20 %></td> > > </tr> > > </table> > > <hr> > > <input type="submit", value="Update"> > > </form> > > > > <%= link_to ''Cancel'', :action => ''list'' %> > > > > (I hope this question hasn''t been answered previously... Gmane''s > > search feature doesn''t seem to be working) > > Post the update action code, that''s where the problem is. > -- > Phillip Hutchings > http://www.sitharus.com/ > sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 4/28/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Here''s the update code: > > def update > @category = Category.find(@params[:id])Compare that with> {"category"=>{"category"=>"dogs", "id"=>"3"}}So I think you want Category.find(@params["category"]["id"])> if @category.update_attributes(@params[:category]) > flash[''notice''] = ''Category was successfully updated.'' > redirect_to :action => ''list'' > else > render_action ''edit'' > end > end > > I believe that that is the automatically generated code (I may have > changed the redirect_to bit.) > > On 4/27/05, Phillip Hutchings <sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 28/04/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m working through the four days on rails tutorial, but I''m stumped. > > > On p. 11-12, you create a custom rhtml page for the edit view. When I > > > submit the changes, I get an error "Couldn''t find Category without an > > > ID". But the ID is being submitted: "Parameters: > > > {"category"=>{"category"=>"dogs", "id"=>"3"}}" > > > > > > Am I missing something, or is this a bug in the tutorial? I''ve found > > > several bugs so far, but so far I''ve been able to figure out the > > > solutions. This one has me stumped, though it might just be that I''m > > > exhausted. > > > > > > BTW, can someone update the version of the tutorial on the RoR page to > > > point to the latest version? The version there is 1.7 & the current > > > version is 1.9. I suspect that at least some of the problems that I''ve > > > found have been fixed by now. > > > > > > Here''s the code from my new edit page: > > > > > > <h1>Rename Category</h1> > > > > > > <form action="/todo/public/categories/update" method="post"> > > > <%= error_messages_for ''category'' %> > > > <%= hidden_field "category", "id" %> > > > > > > <table border=0> > > > <tr> > > > <td><b>Category:</b></td> > > > <td><%= text_field "category", "category", "size" => 20, > > > "maxlength" => 20 %></td> > > > </tr> > > > </table> > > > <hr> > > > <input type="submit", value="Update"> > > > </form> > > > > > > <%= link_to ''Cancel'', :action => ''list'' %> > > > > > > (I hope this question hasn''t been answered previously... Gmane''s > > > search feature doesn''t seem to be working) > > > > Post the update action code, that''s where the problem is. > > -- > > Phillip Hutchings > > http://www.sitharus.com/ > > sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org > > _______________________________________________ > > 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 >-- Cheers Koz
On 28.4.2005, at 09:03, Mike Payson wrote:> Here''s the update code: > > def update > @category = Category.find(@params[:id])<%= hidden_field "category", "id" %> expands to @params[:category][:id] so there is no @params[:id] at hand. That''s probably the reason for you bug. //jarkko> if @category.update_attributes(@params[:category]) > flash[''notice''] = ''Category was successfully updated.'' > redirect_to :action => ''list'' > else > render_action ''edit'' > end > end > > I believe that that is the automatically generated code (I may have > changed the redirect_to bit.) > > On 4/27/05, Phillip Hutchings <sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 28/04/05, Mike Payson <mikepayson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> I''m working through the four days on rails tutorial, but I''m stumped. >>> On p. 11-12, you create a custom rhtml page for the edit view. When I >>> submit the changes, I get an error "Couldn''t find Category without an >>> ID". But the ID is being submitted: "Parameters: >>> {"category"=>{"category"=>"dogs", "id"=>"3"}}" >>> >>> Am I missing something, or is this a bug in the tutorial? I''ve found >>> several bugs so far, but so far I''ve been able to figure out the >>> solutions. This one has me stumped, though it might just be that I''m >>> exhausted. >>> >>> BTW, can someone update the version of the tutorial on the RoR page >>> to >>> point to the latest version? The version there is 1.7 & the current >>> version is 1.9. I suspect that at least some of the problems that >>> I''ve >>> found have been fixed by now. >>> >>> Here''s the code from my new edit page: >>> >>> <h1>Rename Category</h1> >>> >>> <form action="/todo/public/categories/update" method="post"> >>> <%= error_messages_for ''category'' %> >>> <%= hidden_field "category", "id" %> >>> >>> <table border=0> >>> <tr> >>> <td><b>Category:</b></td> >>> <td><%= text_field "category", "category", "size" => 20, >>> "maxlength" => 20 %></td> >>> </tr> >>> </table> >>> <hr> >>> <input type="submit", value="Update"> >>> </form> >>> >>> <%= link_to ''Cancel'', :action => ''list'' %> >>> >>> (I hope this question hasn''t been answered previously... Gmane''s >>> search feature doesn''t seem to be working) >> >> Post the update action code, that''s where the problem is. >> -- >> Phillip Hutchings >> http://www.sitharus.com/ >> sitharus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org / sitharus-QrR4M9swfipWk0Htik3J/w@public.gmane.org >> _______________________________________________ >> 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 >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> @params[:category][:id] so there is no @params[:id] at hand. That''s > probably the reason for you bug.This is the same issue I mentioned running across here: http://news.gmane.org/navbar.php?group=gmane.comp.lang.ruby.rails&article=8489&next=8505&prev=8507&newsrc=,8417,8489,8525 when I pretty where I pretty much hijaacked a thread (My bad -- should have started a new one.) At any rate, when I did the 4 Days tutorial a couple of weeks ago in Rails .09, it worked just fine, as the tutorial said it should. I updated Rails using Gems, just to ''stay current'' and, and when I tried to create a new app using this same technique, I ran into this. So it isn''t so much a tutorial bug as a revision in Rails. Which goes to my original question- How does a noob keep get up to speed with all of this? Thanks, Howard
I''m pretty sure you are right. It has been VERY frustrating working through this tutorial. I''m finding -big- bugs on almost every page of code. But, I''m almost certain that they are (mostly) not the authors errors, but due to changes introduced in the Rails code. Oh, well, I guess that we all want Rails to keep moving forward, so I guess we''ll have to live with it. I just hope that Dave Thomas'' forthcoming book won''t have these same problems. I think I''m just going to give up on actually working through the tutorial, and instead just try to understand what''s going on. It seems that the errors are all factual rather then conceptual, so I hope that I can still get the concepts down well enough to be able to continue without the tutorial. On 4/28/05, Lord Khaos <lordkhaos-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> > > @params[:category][:id] so there is no @params[:id] at hand. That''s > > probably the reason for you bug. > This is the same issue I mentioned running across here: > http://news.gmane.org/navbar.php?group=gmane.comp.lang.ruby.rails&article=8489&next=8505&prev=8507&newsrc=,8417,8489,8525 > > when I pretty where I pretty much hijaacked a thread (My bad -- should > have started a new one.) > > At any rate, when I did the 4 Days tutorial a couple of weeks ago in > Rails .09, it worked just fine, as the tutorial said it should. > I updated Rails using Gems, just to ''stay current'' and, and when I tried > to create a new app using this same technique, I ran into this. So it > isn''t so much a tutorial bug as a revision in Rails. > > Which goes to my original question- How does a noob keep get up to speed > with all of this? > > Thanks, > Howard > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Thu, Apr 28, 2005, Mike Payson wrote:> I''m pretty sure you are right. It has been VERY frustrating working > through this tutorial. I''m finding -big- bugs on almost every page of > code. But, I''m almost certain that they are (mostly) not the authors > errors, but due to changes introduced in the Rails code. Oh, well, I > guess that we all want Rails to keep moving forward, so I guess we''ll > have to live with it. I just hope that Dave Thomas'' forthcoming book > won''t have these same problems. > > I think I''m just going to give up on actually working through the > tutorial, and instead just try to understand what''s going on. It seems > that the errors are all factual rather then conceptual, so I hope that > I can still get the concepts down well enough to be able to continue > without the tutorial.I''ve had exactly the same problems, frustrations, and conclusion. Please let us know if you find something better. In the meantime, like you said, it''s time to just dive in and figure it out. Ben