Forum: Ruby on Rails helper/partial/component best practices??

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.
John MccLain (Guest)
on 2005-12-22 22:20
(Received via mailing list)
I want to build a sortable table and a treeview. Are there examples of
to do this in Rails? If I wanted to componentize this, would I use a
or partial or component (or else) and why?

John McClain
Senior Software Engineer
TCS Healthcare
"Skepticism is the first step toward truth"
Craig A. (Guest)
on 2005-12-27 23:25
(Received via mailing list)
I'd suggest a helper. The other form fields used in rails are all
helpers. This approach lets you write the think in ruby, and have it
available in all views. A helper can be packaged up as a plugin if you
want it to be easily distributed to other people.

The only way in which this might cause you trouble is if you want to be
able to have links on your table which trigger another server query
(whether it's an ajax query of a full page refresh). In this case,
nether helpers or partials will work, since they are just display logic,
and don't include any control handling.

So, if you need to query the server, then you need a controller as well.
In order to 'componentise' such a think for use by third parties, you
may want to make it into a component, however there is a bit of juggling
needed in order to get a component to handle server queries relative to
the current page.

This topic is locked and can not be replied to.