If it is a class, why are you encapsulating it inside a module? You
should be able to put the class rb file in your lib directory and use
it in your controller. Make sure you name the file right. Again if
you need to namespace it inside a module, just include the module in
your controller using a "include ModuleName;" This will remove the
need to do Module::Class every time. You can just use the ClassName
afterwards, you don''t need to box it with a ModuleName::ClassName
On Aug 26, 6:13 pm, Vikas Gholap
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hello all,
>
> I have a module that contains a class as following
>
> my_module.rb
> ------------------
> module MyModule
>
> class MyClass < OtherClass
>
> def my_method(value)
> #process value
> return value
> end
>
> end
>
> end
> --------------------------
>
> In my controller
>
> class MyController < ApplicationController
> include MyModule::MyClass ### How to include module''s class
here
>
> def show
> @result = my_method(value) ### How to access module''s class
method
> here
> end
>
> end
> --------------------------
> but it throws error
> TypeError
> wrong argument type Class (expected Module)
>
> How can I use a module''s class''s method in my controller?
>
> Thanks,
>
> Vikas.
> --
> Posted viahttp://www.ruby-forum.com/.