And then I should be ready to roll with my project.. I have some fine tuning of the looks to do after, but funtionality first! This is probably a rails question.. but I''m not sure where to sign up for the rails questions email group? (I guess I turned this into a 2 question email). I''ll ask here and then if someone will send me the url of where I go to sign up for the rails type questions, that''d be great! now let''s see if i can explain it: (once again using the recipe example provided) by default after you edit a category name, it "redirects" to a showing of the new category name (by id) eg: /category/show/6 because I''ve feverishly edited the show.rhtml (for a different purpose) I get nasty errors after updating the category name. What is the easiest way to change that so it redirects back to say /category/list ? i know that: def show redirect_to :action => ''list'' end will work, but that will kill my current "show" (for category controller): @categories = Category.find_all @recipes = Recipe.find_all @c = @params[''c''] @r = @params[''r''] @recipe = Recipe.find(@params["r"]) is there some way to accomplish this with an if/else statement? I''ve googled high and low.. I can''t seem to find much documentation on controller syntax, so it''s easily errored (anyone have a good site for this? ..please?) my attempts has lead me to such: def show if redirect_to :action => ''list'' else @categories = Category.find_all @recipes = Recipe.find_all @c = @params[''c''] @r = @params[''r''] @recipe = Recipe.find(@params["r"]) end end I just don''t know what to put after the if to say if (url) " /category/show/id# " then redirect_to :action => ''list'' else just pass the params. If anyone can help much appreciated.. (hope that made sense) If I can get it to work I''m willing to pass on my recipe 2.0, if you will, to anyone who cares to take a peek! Thanks again! Ryan
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 MaxSteel wrote:> I''ll ask here and then if someone will send me the url of where I go > to sign up for the rails type questions, that''d be great!www.rubyonrails.com -> Community -> Mailing List> because I''ve feverishly edited the show.rhtml (for a different > purpose) I get nasty errors after updating the category name. > > What is the easiest way to change that so it redirects back to say > /category/list ? > > i know that: > def show > redirect_to :action => ''list'' > endYou are redirecting in the wrong place. Don''t put the redirect in the place where you land, put it where you jump: def update #code to update category... redirect_to :action => ''list'' end - -- David Morton Maia Mailguard - http://www.maiamailguard.com Morton Software Design and Consulting - http://www.dgrmm.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFDzzwhSIxC85HZHLMRAq88AJ9VS7v0QcrrWgQBMZmBAk7fFSi+cgCgnks0 8anhaSO6mis+EzCj+BCrHSE=5AXL -----END PGP SIGNATURE-----
On 1/19/06, MaxSteel <maxsteel at gmail.com> wrote:> > And then I should be ready to roll with my project.. I have some fine > tuning of the looks to do after, but funtionality first! > > This is probably a rails question.. but I''m not sure where to sign up > for the rails questions email group? (I guess I turned this into a 2 > question email).You can find it here: http://rubyonrails.org/community I''ll ask here and then if someone will send me the url of where I go> to sign up for the rails type questions, that''d be great! > > now let''s see if i can explain it: > > (once again using the recipe example provided) > > by default after you edit a category name, it "redirects" to a showing > of the new category name (by id) eg: /category/show/6 > > because I''ve feverishly edited the show.rhtml (for a different > purpose) I get nasty errors after updating the category name. > > What is the easiest way to change that so it redirects back to say > /category/list ? > > i know that: > def show > redirect_to :action => ''list'' > end > > will work, but that will kill my current "show" (for category controller): > @categories = Category.find_all > @recipes = Recipe.find_all > @c = @params[''c''] > @r = @params[''r''] > @recipe = Recipe.find(@params["r"]) > > is there some way to accomplish this with an if/else statement? > > I''ve googled high and low.. I can''t seem to find much documentation on > controller syntax, so it''s easily errored (anyone have a good site for > this? ..please?) > > my attempts has lead me to such: > > def show > if > redirect_to :action => ''list'' > else > @categories = Category.find_all > @recipes = Recipe.find_all > @c = @params[''c''] > @r = @params[''r''] > @recipe = Recipe.find(@params["r"]) > end > end > > I just don''t know what to put after the if to say if (url) " > /category/show/id# " then redirect_to :action => ''list'' > else just pass the params. > > If anyone can help much appreciated.. > > (hope that made sense) > > If I can get it to work I''m willing to pass on my recipe 2.0, if you > will, to anyone who cares to take a peek! > > Thanks again! > RyanYou''re main problem is that you want to modify the scafolding code, but since you followed the tutorial, you are using dynamic which creates the behavior dynamically at runtime, so there isn''t any code to modify. What you need to do is to actually generate the scaffold code. That way it will phsyically exist in files that you can edit and modify. Make a backup of your files before you do this because generating the scaffold code will overwrite stuff. Then open a command window, move to the cook directory, and run the command: ruby script\generate scaffold category category Say yes when for each file it asks to overwrite. Now when you edit catergory_controller.rb you will see all of the scaffolding code and you can change that redirect to show to go somewhere else. Curt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/instantrails-users/attachments/20060119/86ee50ce/attachment.htm
hi David.. I tried what you suggested, it does redirect me back to the right place, however, now it isn''t updating the category name. Once I click update it just returns me to the cat listing. closer! :) On 1/19/06, David Morton <mortonda at dgrmm.net> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > MaxSteel wrote: > > I''ll ask here and then if someone will send me the url of where I go > > to sign up for the rails type questions, that''d be great! > > www.rubyonrails.com -> Community -> Mailing List > > > because I''ve feverishly edited the show.rhtml (for a different > > purpose) I get nasty errors after updating the category name. > > > > What is the easiest way to change that so it redirects back to say > > /category/list ? > > > > i know that: > > def show > > redirect_to :action => ''list'' > > end > > You are redirecting in the wrong place. Don''t put the redirect in the place > where you land, put it where you jump: > > def update > #code to update category... > > redirect_to :action => ''list'' > end > > > - -- > David Morton > Maia Mailguard - http://www.maiamailguard.com > Morton Software Design and Consulting - http://www.dgrmm.net > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFDzzwhSIxC85HZHLMRAq88AJ9VS7v0QcrrWgQBMZmBAk7fFSi+cgCgnks0 > 8anhaSO6mis+EzCj+BCrHSE> =5AXL > -----END PGP SIGNATURE----- > _______________________________________________ > Instantrails-users mailing list > Instantrails-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/instantrails-users >
oooh... very interesting. I will have to try this one.. thanks Curt! On 1/19/06, Curt Hibbs <curt.hibbs at gmail.com> wrote:> > > On 1/19/06, MaxSteel <maxsteel at gmail.com> wrote: > > And then I should be ready to roll with my project.. I have some fine > > tuning of the looks to do after, but funtionality first! > > > > This is probably a rails question.. but I''m not sure where to sign up > > for the rails questions email group? (I guess I turned this into a 2 > > question email). > > You can find it here: > > http://rubyonrails.org/community > > > I''ll ask here and then if someone will send me the url of where I go > > to sign up for the rails type questions, that''d be great! > > > > now let''s see if i can explain it: > > > > (once again using the recipe example provided) > > > > by default after you edit a category name, it "redirects" to a showing > > of the new category name (by id) eg: /category/show/6 > > > > because I''ve feverishly edited the show.rhtml (for a different > > purpose) I get nasty errors after updating the category name. > > > > What is the easiest way to change that so it redirects back to say > > /category/list ? > > > > i know that: > > def show > > redirect_to :action => ''list'' > > end > > > > will work, but that will kill my current "show" (for category controller): > > @categories = Category.find_all > > @recipes = Recipe.find_all > > @c = @params[''c''] > > @r = @params[''r''] > > @recipe = Recipe.find(@params["r"]) > > > > is there some way to accomplish this with an if/else statement? > > > > I''ve googled high and low.. I can''t seem to find much documentation on > > controller syntax, so it''s easily errored (anyone have a good site for > > this? ..please?) > > > > my attempts has lead me to such: > > > > def show > > if > > redirect_to :action => ''list'' > > else > > @categories = Category.find_all > > @recipes = Recipe.find_all > > @c = @params[''c''] > > @r = @params[''r''] > > @recipe = Recipe.find(@params["r"]) > > end > > end > > > > I just don''t know what to put after the if to say if (url) " > > /category/show/id# " then redirect_to :action => ''list'' > > else just pass the params. > > > > If anyone can help much appreciated.. > > > > (hope that made sense) > > > > If I can get it to work I''m willing to pass on my recipe 2.0, if you > > will, to anyone who cares to take a peek! > > > > Thanks again! > > Ryan > > You''re main problem is that you want to modify the scafolding code, but > since you followed the tutorial, you are using dynamic which creates the > behavior dynamically at runtime, so there isn''t any code to modify. What you > need to do is to actually generate the scaffold code. That way it will > phsyically exist in files that you can edit and modify. > > Make a backup of your files before you do this because generating the > scaffold code will overwrite stuff. Then open a command window, move to the > cook directory, and run the command: > > ruby script\generate scaffold category category > > Say yes when for each file it asks to overwrite. Now when you edit > catergory_controller.rb you will see all of the scaffolding code and you can > change that redirect to show to go somewhere else. > > Curt > > _______________________________________________ > Instantrails-users mailing list > Instantrails-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/instantrails-users > >
That helped immensely Curt! Thanks to David as well! Between the two, I was able to determine that it was the update that was botched, and see the scaffolding code allowed me to see and change the redirect. That''s very HANDY to know!! Thanks a bunch for all your help Ryan On 1/19/06, Curt Hibbs <curt.hibbs at gmail.com> wrote:> > > On 1/19/06, MaxSteel <maxsteel at gmail.com> wrote: > > And then I should be ready to roll with my project.. I have some fine > > tuning of the looks to do after, but funtionality first! > > > > This is probably a rails question.. but I''m not sure where to sign up > > for the rails questions email group? (I guess I turned this into a 2 > > question email). > > You can find it here: > > http://rubyonrails.org/community > > > I''ll ask here and then if someone will send me the url of where I go > > to sign up for the rails type questions, that''d be great! > > > > now let''s see if i can explain it: > > > > (once again using the recipe example provided) > > > > by default after you edit a category name, it "redirects" to a showing > > of the new category name (by id) eg: /category/show/6 > > > > because I''ve feverishly edited the show.rhtml (for a different > > purpose) I get nasty errors after updating the category name. > > > > What is the easiest way to change that so it redirects back to say > > /category/list ? > > > > i know that: > > def show > > redirect_to :action => ''list'' > > end > > > > will work, but that will kill my current "show" (for category controller): > > @categories = Category.find_all > > @recipes = Recipe.find_all > > @c = @params[''c''] > > @r = @params[''r''] > > @recipe = Recipe.find(@params["r"]) > > > > is there some way to accomplish this with an if/else statement? > > > > I''ve googled high and low.. I can''t seem to find much documentation on > > controller syntax, so it''s easily errored (anyone have a good site for > > this? ..please?) > > > > my attempts has lead me to such: > > > > def show > > if > > redirect_to :action => ''list'' > > else > > @categories = Category.find_all > > @recipes = Recipe.find_all > > @c = @params[''c''] > > @r = @params[''r''] > > @recipe = Recipe.find(@params["r"]) > > end > > end > > > > I just don''t know what to put after the if to say if (url) " > > /category/show/id# " then redirect_to :action => ''list'' > > else just pass the params. > > > > If anyone can help much appreciated.. > > > > (hope that made sense) > > > > If I can get it to work I''m willing to pass on my recipe 2.0, if you > > will, to anyone who cares to take a peek! > > > > Thanks again! > > Ryan > > You''re main problem is that you want to modify the scafolding code, but > since you followed the tutorial, you are using dynamic which creates the > behavior dynamically at runtime, so there isn''t any code to modify. What you > need to do is to actually generate the scaffold code. That way it will > phsyically exist in files that you can edit and modify. > > Make a backup of your files before you do this because generating the > scaffold code will overwrite stuff. Then open a command window, move to the > cook directory, and run the command: > > ruby script\generate scaffold category category > > Say yes when for each file it asks to overwrite. Now when you edit > catergory_controller.rb you will see all of the scaffolding code and you can > change that redirect to show to go somewhere else. > > Curt > > _______________________________________________ > Instantrails-users mailing list > Instantrails-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/instantrails-users > >
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 MaxSteel wrote:> hi David.. > > I tried what you suggested, it does redirect me back to the right > place, however, now it isn''t updating the category name. Once I click > update it just returns me to the cat listing. > > closer! :)I didn''t tell you how to do the whole thing, just how to redirect... ;) - -- David Morton Maia Mailguard - http://www.maiamailguard.com Morton Software Design and Consulting - http://www.dgrmm.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFDz92aSIxC85HZHLMRAgw5AJ4+1ZWc+s/niY7A5pxTsNm6PeE3DQCfbGDc 4T/JL3NqgDB2j6W+8U+gXwo=TxOU -----END PGP SIGNATURE-----