Hi, A collegue and I have been working through the Rails Todo tutorial, and came across an issue that may have been seen before (but we have not been able to find an existing solution). The problem has been distilled down to when you have a controller method with a class Object method name such as "display" (hash, inspect, etc..) the method definition in the controller is ignored. eg: class TodoController < ApplicationController def display breakpoint "blah" end end We have tracked this down to "hidden_actions" defined in ActionController::Base, it seems that any introspected method names are "disallowed" because of the following: def hidden_actions write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_method) unless read_inheritable_attribute(:hidden_actions) read_inheritable_attribute(:hidden_actions) end As a trial, we''ve been able to alter this behaviour by changing the code to: def hidden_actions write_inheritable_attribute(:hidden_actions, ActionController::Base.public_instance_methods.delete_if {|x| x == "display"}) unless read_inheritable_attribute(:hidden_actions) read_inheritable_attribute(:hidden_actions) end What we are trying to get our heads round, is if this is just one of those things that you have to work with, or is it something that should be bug reported? Any help gratefully received. Cheers, Piers Harding. -- http://www.piersharding.com http://search.cpan.org/~piers/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Lee O''Mara
2005-May-04 16:25 UTC
Re: Rails tutorial, and controller method name "display"
Piers Harding wrote:> A collegue and I have been working through the Rails Todo tutorial, and > came across an issue that may have been seen before (but we have not > been able to find an existing solution). > > The problem has been distilled down to when you have a controller method > with a class Object method name such as "display" (hash, inspect, etc..) > the method definition in the controller is ignored. > eg: > class TodoController < ApplicationController > > def display > breakpoint "blah" > end > > endThere are a number of reserved words, a number of which are listed on the wiki[1] 1.http://wiki.rubyonrails.com/rails/show/Gotcha [snip]> What we are trying to get our heads round, is if this is just one of > those things that you have to work with, or is it something that should > be bug reported?While I can''t speak with authority on the matter of whether it is in fact a bug or not, when I''ve seen this issue come up before the suggested remedy was to rename the method. hth -- Lee
Simon Willison
2005-May-04 16:41 UTC
Re: Rails tutorial, and controller method name "display"
On 4 May 2005, at 17:25, Lee O''Mara wrote:>> What we are trying to get our heads round, is if this is just one of >> those things that you have to work with, or is it something that >> should >> be bug reported? > > While I can''t speak with authority on the matter of whether it is > in fact a bug or not, when I''ve seen this issue come up before the > suggested remedy was to rename the method.I was bitten by this one as well - "display" is a pretty obvious name for a view, so I imagine it happens to a lot of people. It would be great if Rails could throw some kind of warning should you create a controller method that clashes with a reserved word. Cheers, Simon Willison http://simon.incutio.com/
Piers Harding
2005-May-04 19:58 UTC
Re: Rails tutorial, and controller method name "display"
Hi - Thanks for the pointer. I think the thing that threw me in particular about this is that the tutorial (the Todo one) explicitly describes creating a display view, and corresponding method entry in the controller. As I''m sure that the tutorial worked perfectly at the time of writing - it never occured to me (at first) that there might be something wrong with it now, as it seems in retrospect that the Rails API has moved on. This is something that I have no problem with at all - I''m just lookng for clarification, if that''s all that is needed. Cheers, Piers Harding. On Wed, May 04, 2005 at 12:25:45PM -0400, Lee O''Mara wrote:> Piers Harding wrote: > >A collegue and I have been working through the Rails Todo tutorial, and > >came across an issue that may have been seen before (but we have not > >been able to find an existing solution). > > > >The problem has been distilled down to when you have a controller method > >with a class Object method name such as "display" (hash, inspect, etc..) > >the method definition in the controller is ignored. > >eg: > >class TodoController < ApplicationController > > > > def display > > breakpoint "blah" > > end > > > >end > > There are a number of reserved words, a number of which are listed on > the wiki[1] > > 1.http://wiki.rubyonrails.com/rails/show/Gotcha > > [snip] > > >What we are trying to get our heads round, is if this is just one of > >those things that you have to work with, or is it something that should > >be bug reported? > > While I can''t speak with authority on the matter of whether it is in > fact a bug or not, when I''ve seen this issue come up before the > suggested remedy was to rename the method. > > hth > > -- > Lee > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- http://www.piersharding.com http://search.cpan.org/~piers/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Piers Harding
2005-May-04 19:59 UTC
Re: Rails tutorial, and controller method name "display"
That would be useful for people getting started (like me) - I''m not sure how it would be implemented though. Cheers, Piers Harding. On Wed, May 04, 2005 at 05:41:22PM +0100, Simon Willison wrote:> > On 4 May 2005, at 17:25, Lee O''Mara wrote: > >>What we are trying to get our heads round, is if this is just one of > >>those things that you have to work with, or is it something that > >>should > >>be bug reported? > > > >While I can''t speak with authority on the matter of whether it is > >in fact a bug or not, when I''ve seen this issue come up before the > >suggested remedy was to rename the method. > > I was bitten by this one as well - "display" is a pretty obvious name > for a view, so I imagine it happens to a lot of people. It would be > great if Rails could throw some kind of warning should you create a > controller method that clashes with a reserved word. > > Cheers, > > Simon Willison > http://simon.incutio.com/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-- http://www.piersharding.com http://search.cpan.org/~piers/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Michael Koziarski
2005-May-04 20:12 UTC
Re: Rails tutorial, and controller method name "display"
On 5/5/05, Piers Harding <piers-Gn20Leee4l9eoWH0uzbU5w@public.gmane.org> wrote:> That would be useful for people getting started (like me) - I''m not sure > how it would be implemented though.We currently have two tickets open about this: Private Methods should be documented somewhere. http://dev.rubyonrails.org/ticket/751 The reference documentation should include a list of all these ''taken'' method names and Override methods should fail fast http://dev.rubyonrails.org/ticket/751 we could probably use method_added for this, perhaps we can get it done before 1.0> Cheers, > > Piers Harding. > > > On Wed, May 04, 2005 at 05:41:22PM +0100, Simon Willison wrote: > > > > On 4 May 2005, at 17:25, Lee O''Mara wrote: > > >>What we are trying to get our heads round, is if this is just one of > > >>those things that you have to work with, or is it something that > > >>should > > >>be bug reported? > > > > > >While I can''t speak with authority on the matter of whether it is > > >in fact a bug or not, when I''ve seen this issue come up before the > > >suggested remedy was to rename the method. > > > > I was bitten by this one as well - "display" is a pretty obvious name > > for a view, so I imagine it happens to a lot of people. It would be > > great if Rails could throw some kind of warning should you create a > > controller method that clashes with a reserved word. > > > > Cheers, > > > > Simon Willison > > http://simon.incutio.com/ > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > -- > http://www.piersharding.com > http://search.cpan.org/~piers/ > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- Cheers Koz