weakness of helper?

Hi ,
      It comes to me that helper has some weaknesses:
      1) It is hard to test . No easy way to write test code for it.
(or Just i didn't know?)
      2) Not easy to reuse it on other controller/view/model.

      it looks like to that putting the helper code into a model (a
fully helper model , or a mixed model) is good practice.

      However i agree that some html intensive code still sites best
in helper .

     Any idea?

thanks
Kevin

Kevin Yang wrote:

Hi ,
      It comes to me that helper has some weaknesses:
      1) It is hard to test . No easy way to write test code for it.
(or Just i didn't know?)
      2) Not easy to reuse it on other controller/view/model.

      it looks like to that putting the helper code into a model (a
fully helper model , or a mixed model) is good practice.

      However i agree that some html intensive code still sites best
in helper .

     Any idea?

thanks
Kevin

>

1) You can test helpers, using TopFunky's plugin (see
http://nubyonrails.com/articles/test-your-helpers).

2) Well, you don't generally want to reuse them in models - they are
View helpers, after all.

There's been some discussion about presenter patterns in models, but I
don't see a consensus appearing yet (and there's way too much fu in
those discussions for a relative amateur like me to have a view).

However, if you have a pattern which you genuinely need to have in both
the controller and the helper (the current_user is a classic example),
you can define as a provate method in the controler and then make
available to the view by calling helper :some_method in the relevant
controller

Cheers
Chris

Chris T wrote:

Kevin Yang wrote:

Hi ,
      It comes to me that helper has some weaknesses:
      1) It is hard to test . No easy way to write test code for it.
(or Just i didn't know?)
      2) Not easy to reuse it on other controller/view/model.

      it looks like to that putting the helper code into a model (a
fully helper model , or a mixed model) is good practice.

      However i agree that some html intensive code still sites best
in helper .

     Any idea?

thanks
Kevin

>>

1) You can test helpers, using TopFunky's plugin (see
http://nubyonrails.com/articles/test-your-helpers).

2) Well, you don't generally want to reuse them in models - they are
View helpers, after all.

There's been some discussion about presenter patterns in models, but I
don't see a consensus appearing yet (and there's way too much fu in
those discussions for a relative amateur like me to have a view).

However, if you have a pattern which you genuinely need to have in
both the controller and the helper (the current_user is a classic
example), you can define as a provate method in the controler and then
make available to the view by calling helper :some_method in the
relevant controller

Cheers
Chris

Sorry that should be helper_method :some_method
Doh!