Ad

When To Use Helpers Instead Of Partials

- 1 answer

In a rails application, in which situation would you use a partial and when would you use a helper? I find both very similar, since they represent markup fragments.

Is there a convention around this? which is the 'rails way' of using them?

Thanks!

Ad

Answer

I guess my rule of thumb is to use a helper to build a single "unit" of display -- like a span containing a link -- and to use a partial to build a more complex unit of display composed of more than one "unit" of display -- like a grid or a menu.

Ad
source: stackoverflow.com
Ad