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

  • Home
  • SEARCH
  • 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 3498732
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:31:32+00:00 2026-05-18T12:31:32+00:00

New Rails programmer here. There is probably a pretty simple solution to this, but

  • 0

New Rails programmer here. There is probably a pretty simple solution to this, but I just can’t figure it out. Here’s the deal: lets say I have many posts on a single page. Each post has a content field, and some of those content fields contain #hashtags within the content.

I want to develop an algorithm that scans the content of every single post (say, every 2 seconds) and displays a list of every hashtag. I’m thinking AJAX will be necessary, because the posts feature AJAX edit-in-place. Thus, if a post is changed and a new hashtag is created, the hashtag list should be updated automatically to reflect this. Also, each hashtag on the hashtag list should be clickable, sending a search query and in turn displaying the posts that contain the selected hashtag.

This end result is similar to tagging and a tag cloud, but should be dynamic and integrated (as opposed to having a tag field for each post). I don’t want to attach any tags to the posts as a database column. I just want the application to scan the content of every single post and display a clickable hashtag list.

All suggestions are greatly appreciated.

  • 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-05-18T12:31:32+00:00Added an answer on May 18, 2026 at 12:31 pm

    Personally, I would use jQuery to implement the AJAX functionality you need. Javascript will be used to check the server for new hashtags, and the actual hashtag searching will be done on the server. In your Post model, you could have something like this to do the actual searching:

    class Post < ActiveRecord::Base
      # class methods
      class << self
        def hashtags
          tags = []
    
          # cycle through all posts that contain a hashtag, and add them to list
          Post.all(:conditions => 'body like "%#"').each do |post|
            tags += post.hashtags
          end
    
          # remove duplicates and sort alphabetically
          tags = tags.uniq.sort
        end
      end
    
      # instance methods
      def hashtags
        @hashtags ||= body.scan(/#\w+/)
      end
    end
    

    There are two methods here with the same name, but one is called on the class (Post.hashtags) to get all hashtags across all posts, and the second one is called on a single instance (post.hashtags) to get just the hashtags from that post.

    There are several other pieces to the puzzle – your controller code, your views, and your javascript. This question is a tall order for a volunteer site. You’re asking for several different things to be done for you.

    My advice is to start building this as I’ve described, and ask for help on the pieces that you have trouble with along the way. We’re more than happy to help, but you’re asking for an entire javascript-driven MVC stack. Try to limit your questions to something that can be answered in 5-10 minutes, and you’re likely to get a lot more feedback and help.

    Good luck!

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

Sidebar

Related Questions

Here's the setup: New Rails app, then put this test_rake.rake in lib/tasks: task :testclass
I'm a new Rails programmer working on a web app. As part of this
Starting a new rails project and we have a well-thought-out color palette, and want
I just created a new rails app in Rails 3.1.1, and my application layout
I've just started a brand new rails project and the first task I'm trying
I am trying to start a new Rails project but I am getting a
new rails user here. I have a rails project that I want to accept
Just setup a new rails 3.1.3 app using mysql (mysql2 gem) on CentOS 5
I'm creating a new rails app for my business, and I just finished a
SOLUTION FOUND: See comment Building a new rails 3.1 app. Started with a basic

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.