Forum: Ruby on Rails Modularisation: Using helper generating HTML output vs. using partials

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6f3f4fcb842db4b755cd8adc8bca67c6?d=identicon&s=25 ms (Guest)
on 2008-10-16 16:37
(Received via mailing list)

I've got a general question: when do I use helper and when I do use
partials to modularise certain gui elements?

For example: I've got a faq list. Each item can be folded and unfolded
using ajax.

FAQ foo
-> question 1
-> question 2
-> question 3

So, I wrote a helper "faq_li_tag(args)" which takes the question and
answer for parameters and generates the HTML output.

But I also could have made a partial which creates the corresponding

What's the best solution? What are the criterias for this decision in

Thank you very much!

Best regards,
8217faf2bfdfa7daf10135d41ddd421e?d=identicon&s=25 Jeff Cohen (jeff)
on 2008-10-16 17:18
(Received via mailing list)
On Oct 16, 9:22 am, ms <> wrote:
> -> question 2
> Thank you very much!
> Best regards,
> ms

I use partials to factor out view templates to make them more
readable, and so that I can reuse portions of a view in other

I use helpers whenever view logic is starting to get intertwined with
the view code.  So presentation-only code is in the views/partials,
and any logic (is this user an admin? should they see a sidebar now?
etc.) goes into helpers.

This topic is locked and can not be replied to.