Should I Add String Conditional Method to Helper or Model or ...? <p>What is the best way to do this?</p> <p>I have this in a view <code>&lt;%= badges(challenge) %&gt;</code> or <code>&lt;%= challenge.badges %&gt;</code> depending on if I put <code>badges</code> in a helper or the model.</p> <p>I was told to put it in a helper. I put it in so like this:</p> <pre><code>module ChallengesHelper def badges(challenge) if challenge.name == "Read 20 Min" ActionController::Base.helpers.image_tag("read.png", class: "gold-star") elsif challenge.name == "Exercise 20 Min" ActionController::Base.helpers.image_tag("exercise.png", class: "gold-star") elsif challenge.name == "Meditate 10 Min" ActionController::Base.helpers.image_tag("meditate.png", class: "gold-star") elsif challenge.name == "Stretch 5 Min" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Write 500 Words" ActionController::Base.helpers.image_tag("write.png", class: "gold-star") elsif challenge.name == "Walk 5,000 Steps" ActionController::Base.helpers.image_tag("walk.png", class: "gold-star") elsif challenge.name == "Eat Fruit &amp; Veg" ActionController::Base.helpers.image_tag("fruit-and-vegetable.png", class: "gold-star") elsif challenge.name == "Plan Day" ActionController::Base.helpers.image_tag("plan.png", class: "gold-star") elsif challenge.name == "After Waking, Guzzle Water" ActionController::Base.helpers.image_tag("water.png", class: "gold-star") elsif challenge.name == "Track Food Consumption" ActionController::Base.helpers.image_tag("track-food.png", class: "gold-star") elsif challenge.name == "Random Act of Kindness" ActionController::Base.helpers.image_tag("random-kindness.png", class: "gold-star") elsif challenge.name == "Write 3 Gratitudes" ActionController::Base.helpers.image_tag("gratitude.png", class: "gold-star") elsif challenge.name == "Juice Fast" ActionController::Base.helpers.image_tag("juice.png", class: "gold-star") elsif challenge.name == "Not Smoke" ActionController::Base.helpers.image_tag("not-smoke.png", class: "gold-star") elsif challenge.name == "Not Drink Alcohol" ActionController::Base.helpers.image_tag("not-drink.png", class: "gold-star") # GOAL CHALLENGES elsif challenge.name == "Live Abroad" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Long Road Trip" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Tour Capital Building" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Karaoke" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "See New York Skyline" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Run 5K" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Write Memoir" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Lose 10 Pounds" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Join Club" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Skydive" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Start a Blog" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Donate $100 to Charity" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Create Independent Income Stream" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Paint a Picture" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif challenge.name == "Give a Public Speech" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") else ActionController::Base.helpers.image_tag("gold-star-maze.png", class: "gold-star") end end end </code></pre> <p>I'm only concerned because it seems more "wordy" in the helper than the model.</p> <pre><code> def badges if name == "Read 20 Min" ActionController::Base.helpers.image_tag("read.png", class: "gold-star") elsif name == "Exercise 20 Min" ActionController::Base.helpers.image_tag("exercise.png", class: "gold-star") elsif name == "Meditate 10 Min" ActionController::Base.helpers.image_tag("meditate.png", class: "gold-star") elsif name == "Stretch 5 Min" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Write 500 Words" ActionController::Base.helpers.image_tag("write.png", class: "gold-star") elsif name == "Walk 5,000 Steps" ActionController::Base.helpers.image_tag("walk.png", class: "gold-star") elsif name == "Eat Fruit &amp; Veg" ActionController::Base.helpers.image_tag("fruit-and-vegetable.png", class: "gold-star") elsif name == "Plan Day" ActionController::Base.helpers.image_tag("plan.png", class: "gold-star") elsif name == "After Waking, Guzzle Water" ActionController::Base.helpers.image_tag("water.png", class: "gold-star") elsif name == "Track Food Consumption" ActionController::Base.helpers.image_tag("track-food.png", class: "gold-star") elsif name == "Random Act of Kindness" ActionController::Base.helpers.image_tag("random-kindness.png", class: "gold-star") elsif name == "Write 3 Gratitudes" ActionController::Base.helpers.image_tag("gratitude.png", class: "gold-star") elsif name == "Juice Fast" ActionController::Base.helpers.image_tag("juice.png", class: "gold-star") elsif name == "Not Smoke" ActionController::Base.helpers.image_tag("not-smoke.png", class: "gold-star") elsif name == "Not Drink Alcohol" ActionController::Base.helpers.image_tag("not-drink.png", class: "gold-star") # GOAL CHALLENGES elsif name == "Live Abroad" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Long Road Trip" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Tour Capital Building" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Karaoke" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "See New York Skyline" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Run 5K" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Write Memoir" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Lose 10 Pounds" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Join Club" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Skydive" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Start a Blog" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Donate $100 to Charity" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Create Independent Income Stream" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Paint a Picture" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") elsif name == "Give a Public Speech" ActionController::Base.helpers.image_tag("stretch.png", class: "gold-star") else ActionController::Base.helpers.image_tag("gold-star-maze.png", class: "gold-star") end end </code></pre> <p>Why is one spot better than the other? And what is the best practice for something like this where their are a lot of string conditions?</p>