oo00oo
2006-Feb-09 23:12 UTC
How to call a standard function from a class inside the lib folder ?
Hello, I try to use url_for from a class inside the lib folder class Test def self.mytest options url = url_for( options ) end end But I have this error : *undefined method `url_for'' for Test:Class* How can I use it ? Thanks _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Kent Sibilev
2006-Feb-09 23:37 UTC
[Rails] How to call a standard function from a class inside the lib folder ?
There is no such thing as a standard function. url_for method belongs
to ActionController::Base class. So you can pass a reference of your
controller to your mytest method like
class Test
def self.mytest controller, options
url = controller.url_for( options )
end
end
Kent.
On 2/9/06, oo00oo <oo00oo@free.fr> wrote:> Hello,
>
> I try to use url_for from a class inside the lib folder
>
> class Test
> def self.mytest options
> url = url_for( options )
> end
> end
>
> But I have this error :
>
> *undefined method `url_for'' for Test:Class*
>
> How can I use it ?
>
> Thanks
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
oo00oo
2006-Feb-10 15:34 UTC
[Rails] How to call a standard function from a class inside the lib folder ?
Ok, thanks. Not easy to use lib finally> There is no such thing as a standard function. url_for method belongs > to ActionController::Base class. So you can pass a reference of your > controller to your mytest method like > > class Test > def self.mytest controller, options > url = controller.url_for( options ) > end > end > > Kent. > >