Wouldn''t it be more natural to write the helper methods in modules
that you''d mix into the controller using extend and include?
On Apr 28, 6:26 am, Alex Moore
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I''m implementing a helper library which provide both view helpers
and
> controller helpers. To save the end user from having to specifically
> pass in a reference to self on every call I was wondering if there was a
> way for a class to get access to the calling controller object
> automagically.
>
> One suggestion was Thread.current[:controller] .. but that sounds a bit
> nasty
>
> e.g.
>
> class MyTestController < ActionController:Base
> def test
> @ref = MyModule::MyClass.new({:a_load_of_settings => ''go
here''})
> end
> end
>
> module MyModule
> class MyClass
> def initialize(settings ={})
> #I need a reference to the controller
> end
> end
> end
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---