When to use Helpers instead of Partials

后端 未结 6 358
不知归路
不知归路 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:30

    I use partials as subtemplates (i.e., something with lots of markup that gets used again and again, like a blog post blurb), and helpers to handle display more logic-y things (a div that's only visible to admins, for instance).

提交回复
热议问题