When to use Helpers instead of Partials

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

    Partials are the part of view which can have bunch of HTML code along with ruby code. You can also use the partials in controller in render method.

    In case of helpers, you can have methods for short html piece of code. You can have some calculations related methods which you want to use in your view file.

提交回复
热议问题