Ruby on Rails
Tuesday, March 1, 2011
On Tue, Mar 1, 2011 at 10:13 AM, Pale Horse <lists@ruby-forum.com> 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:
Advantages of this approach:
- 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.
- You could send the names as a string like " name1 | name2 | name3 | ....| " or simply pass a hash.
- 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.
Advantages of this approach:
- 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.
- Use javascript libraries when it comes to things like these, until and unless you want to save the changes(matches here) in DB.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment