Is there a way to call or invoke a controller method from script/console or script/runner? The reason is that I''d like to pre-cache some of the actions on my controller. The pseudo code below is what I''d like to be able to do: class MyController < ApplicationController caches_action :test def test puts ''Hi there'' end end script/console:>> MyController.test=> ''Hi there'' Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2007-Mar-26 22:57 UTC
Re: Calling a controller action from script/console or runner
Hi Mark, it seems that you''re trying to invoke an instance using class method syntax. Thus, you''ll need to do the following in script/console: 1) controller = MyController.new <RETURN> 2) controller.test <RETURN> Good luck, -Conrad On 3/26/07, Mark <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Is there a way to call or invoke a controller method from script/console > or script/runner? The reason is that I''d like to pre-cache some of the > actions on my controller. > > The pseudo code below is what I''d like to be able to do: > > class MyController < ApplicationController > > caches_action :test > > def test > puts ''Hi there'' > end > > end > > script/console: > >> MyController.test > => ''Hi there'' > > > Thanks. > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I see, cool. Thanks Conrad! Do you think that''s the best way to pre-cache some of the controller''s actions? Thanks. Conrad Taylor wrote:> Hi Mark, it seems that you''re trying to invoke an instance using class > method syntax. Thus, you''ll need to do the following in > script/console: > > 1) controller = MyController.new <RETURN> > > 2) controller.test <RETURN> > > Good luck, > > -Conrad-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---