Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:26:13+00:00 2026-06-11T01:26:13+00:00

I have a pretty basic blog app on rails, and I need help creating

  • 0

I have a pretty basic blog app on rails, and I need help creating a method.

For each post, the user has to specify a neighborhood, and for styling purposes, I want to find out if that neighborhood falls in a certain bucket so I can color that post accordingly. For instance, the neighborhood “SOMA” is a part of the bucket “Downtown.”

I imagined that what I would do is pass the neighborhood into a method that determines which bucket it falls in and I can somehow output the bucket to correspond to a div class in the index. Open to other suggestions.

Does anyone know where a method like this would live?

Update:

I added a barebones method in PostsHelper to even see if it works, then i can flesh out the logic

module PostsHelper

def bucket(neighbor)
    case neighbor
        when "SOMA"
        puts "Downtown"

        when "Mission"
        puts "Dolores"

        else
        puts "foo"
    end

end

end

Then I tried calling the method in the post index and nothing happens. This may be the dumbest question ever, but what am I missing? Is this even the right way to go about it?:

<ul id="post-list">
<% @posts.each do |post| %>

<li><%= post.content %></li>
<li><%= post.attribution %> in <%= post.neighborhood %> 
<span class="post-date"><%=time_ago_in_words(post.created_at) %> ago</span></li>
<li> <%= bucket(yield(post.neighborhood)) %> </li> 

<% end %>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:26:15+00:00Added an answer on June 11, 2026 at 1:26 am

    This kind of methods should live in a decorator.

    See this railscast: http://railscasts.com/episodes/286-draper


    Edit after your details

    def bucket(neighbor)
      case neighbor
      when "SOMA"    then "Downtown"
      when "Mission" then "Dolores"
      else
        "foo"
      end
    end
    

    In your view:

    <li> <%= bucket(post.neighborhood) %> </li>
    

    But you should really consider using decorators.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty basic 'User' model, control & views for a Rails app.
I am writing a pretty basic php app and have created a pretty big
I have a pretty basic app flow that is quite linear, so it fits
I have a pretty basic Paperclip Upload model that is attached to a User
I have a pretty basic internal iOS app that I want to send a
I have a pretty basic windows form app in .Net. All the code is
I have a user control that is pretty basic. It contains several TextBox controls,
I have a pretty basic database. I need to drop a good size users
I have a pretty basic X11 app that I run on Linux that I'm
I might have pretty basic question about regex. I have the following regex, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.