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 8093575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:31:52+00:00 2026-06-05T20:31:52+00:00

In my app I have a article and comment model. I implemented a reply-feature,

  • 0

In my app I have a article and comment model. I implemented a reply-feature, so that a user can reply to another comment by simply putting the id of the comment they want to quote in the comment form like this: #26 (to quote comment with id 26). This all works fine, with the regex and reply to user_id attr:
extract from my comments_controller create action:

  if @comment.content.match(/(#([1-9]+))\s/)
  iteration_fragment = $2
  iteration_id = %Q{#{ iteration_fragment }}
  if @replied_to_comment = @article.comments.where(:iteration_id => iteration_id).first
    @comment.in_reply_to_user_id = @replied_to_comment.user_id
  end
  end

Now, without creating a new model, I just want to put a ‘html helper layer’ on top of my comment system, so that these fragments such as “#33” automatically are converted to a “#33” onmouseover link, showing the content of comment 33 onmouseover. So I don’t want bb code quoting, but rather be really minimalist.
Does anybody know, what I’m looking for and how it should be approached?

  • 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-05T20:31:53+00:00Added an answer on June 5, 2026 at 8:31 pm

    The word automatic makes me think that the only way you could do this is with jQuery..

    $("input#your_selected_input").keyup(function(){
      $this = $(this);
      if ($this.val().match(/(#([1-9]+))\s/) {
        $matches = $this.val().match(/(#([1-9]+))\s/
        $this.parent().after($this.html().replace( $matches[0], $("<a/>").html()));
      }
    });
    

    That’s the automatic part..

    To make the page load with the content in Rails, it would be something like :

    In your comment model

    def special_sauce_text
       matches = content.match(/(#([1-9]+))\s/)
       magic_sauce_links = []
       new_content = content
       if matches.present?
         for match in matches do
           magic_sauce_link << link_to(match, match, :class => 'your-special-stuff')
           new_content.gsub(match, magic_sauce_link)
         end
       end
       return new_content
    end
    

    Then you apply it liberally with :

    Comment.special_sauce_text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have datetime input in my ASP.NET MVC3 app: <div class=editor-field> @Html.EditorFor(model => model.Article.PublishedDate)
I have a really simple Rails app. Basically an article with comments. I want
I have an Ember.js app as follows (borrowed from this article on andyMatthews.net): View:
I have a simple cakephp app with table articles that has a cat_id column
I have a GWT app that have a HorizontalPanel that span across the width
I have app that sometimes crashes in navigating through Navigation bar and in console
I have found article that skims over this. But my main question is do
According to this Wikipedia article on Google App Engine : Developers have read-only access
I have an app with a login screen with a button that invites users
I have an app called CMS with Category and Article. Quite simple. I overwrite

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.