Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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:</p> <pre><code>class Post &lt; ActiveRecord::Base # class methods class &lt;&lt; self def hashtags tags = [] # cycle through all posts that contain a hashtag, and add them to list Post.all(:conditions =&gt; '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 </code></pre> <p>There are two methods here with the same name, but one is called on the class (<code>Post.hashtags</code>) to get all hashtags across all posts, and the second one is called on a single instance (<code>post.hashtags</code>) to get just the hashtags from that post.</p> <p>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.</p> <p>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.</p> <p>Good luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload