When to choose a partial or helper or a loop in view.
Specifically, when we need a repeated structure only in a single page.
I would like to know which one is a best practice from DRY point of view and Performance point of view.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If only in a single page, as described, I would consider using a loop or partial.
– If the output is one or two lines I might just use a loop.
– If more than that a partial
If used in multiple pages I would use a helper.
Overall I prefer helpers as they feel like a more object oriented, ruby approach and they are easy and great to have tests for!