Home>

Both are used in a view, and duplicate content is summarized.
I understand this, but I don't understand how to use it and when.
As a result of the investigation,
Helper → Library called from template
Partial →.html.erb
Was mentioned, but the meaning was not clear.
It's a very elementary content, but can you tell me?

  • Answer # 1

    Think of partial as a subroutine in html.erb.
    If you write a similar description many times or it is too long and the whole view becomes difficult to understand, it is used when you make it a partial with a name that understands "what to view" and go out ..

    helper can make something like returning html,
    Write a method that returns a value when you need to perform a complicated calculation to obtain the value to be displayed in the view.
    Please note that it is better to write in model if you can write it as method of model.