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

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.
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
how
to do this in Rails? If I wanted to componentize this, would I use a
helper,
or partial or component (or else) and why?

John McClain
Senior Software Engineer
TCS Healthcare
removed_email_address@domain.invalid
(530)886-1700x235
"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.

Craig
This topic is locked and can not be replied to.