This will probably seem like a dumb question but how do you determine the active controller through code? Essentially what I''m trying to do is build some logic into a base controller that looks up what the active controller is to build navigation. Also, how do you access server variables, such as PATH_INFO or SCRIPT_NAME, things like that in Rails? Kyle Heon kheon-Wuw85uim5zDR7s880joybQ@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 7/12/05, Kyle Heon <kheon-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> > > This will probably seem like a dumb question but how do you determine the > active controller through code?Here is an example: <% case controller.controller_name when "context" add_string = "Add a next action in this context »" when "project" add_string = "Add a next action in this project »" else add_string = "Add a next action »" end %> -- Nicholas Lee http://stateless.geek.nz gpg 8072 4F86 EDCD 4FC1 18EF 5BDD 07B0 9597 6D58 D70C
Thanks for the code sample, I''m learning Ruby as I go. That works from within the view but not from within the controller itself. What is the trick to get this access within the superclass? Kyle Heon kheon-Wuw85uim5zDR7s880joybQ@public.gmane.org -----Original Message----- From: Nicholas Lee [mailto:emptysands-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] Sent: Tuesday, July 12, 2005 7:41 PM To: kheon-Wuw85uim5zDR7s880joybQ@public.gmane.org; rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] How to determine current controller On 7/12/05, Kyle Heon <kheon-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> > > This will probably seem like a dumb question but how do you determine > the active controller through code?Here is an example: <% case controller.controller_name when "context" add_string = "Add a next action in this context »" when "project" add_string = "Add a next action in this project »" else add_string = "Add a next action »" end %> -- Nicholas Lee http://stateless.geek.nz gpg 8072 4F86 EDCD 4FC1 18EF 5BDD 07B0 9597 6D58 D70C
Hi Kyle, from the controller just use ''controller_name'' bests, Richard> Thanks for the code sample, I''m learning Ruby as I go. > > That works from within the view but not from within the controller itself. > What is the trick to get this access within the superclass? > > Kyle Heon > kheon-Wuw85uim5zDR7s880joybQ@public.gmane.org