Forum: Ruby on Rails Helper Classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A0599814ceddc2e283792f4e47c57f5e?d=identicon&s=25 Brian Takita (Guest)
on 2005-12-13 00:38
(Received via mailing list)
Hello,

Helper methods are currently implemented as modules that, I assume, are
included in the ActionView class in the context of the ActionView.

This is fine for simple views, but it seems like it may cause problems
when
the views get more complicated.

Some tight coupling will start to happen If the helper grows and grows
and
gets a bunch of methods. You could move some of the methods to another
helper module, but the object still has all of the methods. This would
make
it more difficult to unit test the helper since there is potentially
some
tight coupling going on.

Also, there is the possibility of name collision. One can start pluggin
in
one of the many 3rd party helpers (
http://wiki.rubyonrails.com/rails/pages/3rd+Party+Helpers), but what if
two
of the 3rd party modules have the method :render_this?

I think making the helpers into classes would solve these issues, for
the
same reasons why object oriented code handles complexity better than
procedural oriented code.

Has anybody used Helper Classes? If so, what is a Rails friendly
convention
of doing so? For example, would the helper classes go into the
app/helpers
directory or in the same directory as the view (app/views/viewname)?

Are there any examples out there?
A0599814ceddc2e283792f4e47c57f5e?d=identicon&s=25 Brian Takita (Guest)
on 2005-12-13 00:50
(Received via mailing list)
are included in the ActionView class in the context of the ActionView.


I meant to say

are included in the ActionView object.
This topic is locked and can not be replied to.