On Tue, Mar 1, 2011 at 10:13 AM, Pale Horse <[email protected]> wrote:

> The application I'm currently working on has a Glossary model. The
> Glossary table has columns for the term and its definition.
>
> The application also has Pages which have content. The content needs to
> highlight any words that match a term in the Glossary table.
>
> There'll be a few ways to do this but I'd appreciate your advice on the
> way you'd accomplish this.
>
> Yes, there are a lot of ways to do this. My approach would be:

   1. Send the names of all the Glossary as json object when you load the
   page, bcoz you will be matching the contents of pages with names, i guess.
   2. You could send the names as a string like " name1 | name2 | name3 |
   ....| " or simply pass a hash.
   3. Now, when you display the contents of a page, use jQuery to do the
   matching on the names json with the contents in the http_response coming
   from server.

How you want to do the matching would determine, in which format you are
sending the names json from server.

Advantages of this approach:

   1. You are not saving the matches in DB, although you can. But if you
   change your glossary, you would have to do it again and change the matches
   for each page's contents. You would have understood what I mean to convey
   here.
   2. Use javascript libraries when it comes to things like these, until and
   unless you want to save the changes(matches here) in DB.

There could be a better way of doing this, so lets wait and see what the
experienced ones here say about it.


--
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to