Hello all. This is a strange question, but ... Is there some issue with name an action ''basket''? Like so, class ShopController < ApplicationController def basket ... < do stuff > ... end end The reason I ask is because when I created the above action along with an accompanying basket.rhtml template, the application ignored the action entirely and went right to rendering the template, no questions asked. No matter what I did in the ''basket'' action, it was ignored. There wasn''t a heckuvalot going on in either the controller or the view, and the model, in this case, was not an issue, since the controller and view are merely dealing with a @session variable which is standing in for a model class. The moment I renamed the action and template to ''show_basket'', everything worked fine. I realize this is a little like a "Doctor-it-hurts-when-I-do-this" question, but I would be interested in knowing the answer. It''s not good when things work for mysterious reasons ... Any insights are appreciated. All the best, Greg
Greg McClure wrote:> Hello all. > > This is a strange question, but ... > > Is there some issue with name an action ''basket''? Like so, > > class ShopController < ApplicationController > def basket > ... < do stuff > ... > end > end > > The reason I ask is because when I created the above action along with > an accompanying basket.rhtml template, the application ignored the > action entirely and went right to rendering the template, no questions > asked. No matter what I did in the ''basket'' action, it was ignored. > There wasn''t a heckuvalot going on in either the controller or the > view, and the model, in this case, was not an issue, since the > controller and view are merely dealing with a @session variable which > is standing in for a model class. > > The moment I renamed the action and template to ''show_basket'', > everything worked fine. > > I realize this is a little like a "Doctor-it-hurts-when-I-do-this" > question, but I would be interested in knowing the answer. It''s not > good when things work for mysterious reasons ... > > Any insights are appreciated. >It might not be that useful but I just created an action called basket with a simple render :text => '''' method call. This displayed the text as expected. I created a basket.rhtml template but this was ignored as the explicit render in the basket action took preference. Once I removed the render call in the action, the basket.rhtml template displayed as expected. Maybe the problem comes (somehow) from your use of the session? Chris
> Maybe the problem comes (somehow) from your use > of the session?I thought this might be the case, but I was so frustrated after dealing with the problem last night that I didn''t test it out. I''ll give it a go today. Thanks for testing this on your own, I appreciate it. I thought I might be stepping on some heretofore unheard of namespace or something, but that doesn''t seem to be it either. Strange problem. All the best, Greg
François Beausoleil
2005-Aug-23 17:07 UTC
Re: Issue with ''basket'' action ... ??? Wha ... ?
Hello Greg, Greg McClure said the following on 2005-08-23 03:18:> Hello all. > > This is a strange question, but ... > > Is there some issue with name an action ''basket''? Like so, > > class ShopController < ApplicationController > def basket > ... < do stuff > ... > end > endAre you sure the method is not protected ? If you do def ShopController < ApplicationController # Some actions protected def helpers end def basket end end Then your basket action won''t be called - it needs to be public. Hope that helps, François
Thanks, François, for your suggestion. Strangely, no, the method is not protected. As soon as I changed the name of the method only, to ''show_basket'', it worked fine. All the other methods in the class work as expected, too. Last night, if I changed the method back to ''basket'', it stopped working. The classes are really barebones, I don''t have any obvious opportunities for namespace collisions, at least not that I can see, but the code is very simple and there''s not a whole lot to miss. Also, there was only one ''basket'' method in the application, in the ShopController class. I grepped the both the project directories and the gems directories where the rails classes reside, looking for instances of "\<basket\>", but there''s nothing which cropped up to indicate that that method name steps on anything else. I think it may be related, somehow, to a session variable. I''m referencing it like so, "@session[:basket]", and perhaps that''s what''s messing up. I''m going to change some names around later and see if that''s it, but if anyone else has any more suggestions, I''d sure like to hear them. Peace, Greg On 8/23/05, François Beausoleil <fbeausoleil-IQIa899fVSs@public.gmane.org> wrote:> Hello Greg, > > Greg McClure said the following on 2005-08-23 03:18: > > Hello all. > > > > This is a strange question, but ... > > > > Is there some issue with name an action ''basket''? Like so, > > > > class ShopController < ApplicationController > > def basket > > ... < do stuff > ... > > end > > end > > Are you sure the method is not protected ? If you do > def ShopController < ApplicationController > # Some actions > protected > def helpers > end > > def basket > end > end > > Then your basket action won''t be called - it needs to be public. > > Hope that helps, > François > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >