Jian Lin wrote:
> I wonder if a Ruby on Rails developer has encounter this before: suppose
> it is a long article (say 100,000 words), and I need to write a Ruby
> file to display page 1, 2, or page 38 of the article, by
> 
> display.html.erb?page=38
> 
> but the number of words for each page can change over time (for example,
> right now if it is 500 words per page, but next month, we can change it
> to 300 words per page easily

Why divide it in the database? Store it one field in the database, and 
when you fetch it from the database just perform the logic to find 
page=38 and then display that.

If actual testing indicates that's too slow with the actual quantity of 
data you expect, then you'd have to perform a word-boundary calculation 
on inserting the value in the db, and store the results as an 'index' to 
the text somehow.

Either way, I don't see any reason to actually split up the text file in 
the db. Unless you want to let the user _search_ for, say, word X on 
page N of the text. But then you're getting into complicated enough text 
searching land that I'd investigate using something like lucene/solr to 
index your text, instead of an rdbms, and seeing what support for 
page-boundary-based-searching eg lucene/solr have.
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to