Hey Mike,
Depending on what you want to do you have a few options:
1) Instantiate an object of your new class in any particular controller action
2) Add a before filter to Application controller that initializes an
instance variable to the new instance
* you should probably also declare accessors for this instance
variable in Application controller
2) Add a before filter to one of your controllers that initializes an
instance variable to the new instance
3) Write a module instead of a class and
a) include it in Application controller (it's then available as
instance method in any controller)
b) include it in one of your controllers (it' then available as
instance method in this controller only)
c) extend it in Application controller (it's then available as
class method in any controller)
d) extend it in one of your controllers (it' then available as
class method in this controller only)
e) a combination of include/extend to have class and instance methods
Hope that helps
cheers
snusnu
On Thu, Apr 30, 2009 at 14:35, mike <[email protected]> wrote:
>
> Hi,
> My problem is that i would extend Controller with my own class (the
> idea is to access the request object from my class).
> And so, be able to call my class in the controller in a way like :
>
> Myclass.new
> toto = Myclass.test
> ....
>
> Do you have an idea ? i'm not so great in all this extend stuff yet
> myself.
>
> Thx.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---