When to use Helpers instead of Partials

后端 未结 6 365
不知归路
不知归路 2020-12-05 13:03

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.

6条回答
  •  青春惊慌失措
    2020-12-05 13:35

    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.

提交回复
热议问题