Hi, What''s the recommended method of accessing helper methods from controllers? For example, if I wanted to use the pluralize method from ActionView::Helpers::TextHelper in one of my controllers for flash messages, how would I make it accessible? Many thanks, Jordan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jordan Elver wrote:> Hi, > What''s the recommended method of accessing helper methods from > controllers? > For example, if I wanted to use the pluralize method from > ActionView::Helpers::TextHelper in one of my controllers for flash > messages, how would I make it accessible? > > Many thanks, > JordanBecause the use of helpers is discouraged in controllers (as you are supposed to use them on views) is a little hard to do that. One option could be: aht= ActionView::Helpers::TextHelper aht.module_eval do module_function :pluralize end Then you could do: flash[:notice]= aht.pluralize("thing") Not very nice tough... :) -- 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 -~----------~----~----~----~------~----~------~--~---
> Because the use of helpers is discouraged in controllers (as you are > supposed to use them on views) is a little hard to do that. One option > could be: > > aht= ActionView::Helpers::TextHelper > > aht.module_eval do > module_function :pluralize > end > > Then you could do: > > flash[:notice]= aht.pluralize("thing") > > Not very nice tough... :)No, but I''ll give it a try :) Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---