Re: [Rails] Please help to DRY snippet

14 views
Skip to first unread message

Dave Aronson

unread,
Feb 24, 2014, 9:10:28 AM2/24/14
to rubyonrails-talk
On Mon, Feb 24, 2014 at 7:35 AM, Роман Ярыгин <330...@gmail.com> wrote:

> Please, help me to DRY this code snippet. The task is to print div content,
> but to print it in div, when i%17 ==0 and make it without div, when not.

A view helper method would do the trick. Make one that returns the
bit that stays the same (the link_to, strong, comma, and server
address), then call it where you have those things.

Or you could use a decorator that contains the logic of looking at i.

-Dave

--
Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us);
FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014;
creator of Pull Request Roulette, at PullRequestRoulette.com.
Reply all
Reply to author
Forward
0 new messages