Rails Pagination for Articles / Strings?
I am aware and have regularly used Rails will_paginate. It's worked well for collections. Now, I'd like to use it to paginate a string. The application is paginating a long article. The article is a string and paginate expects a collection. I am not 开发者_如何学Pythonsure what to do. Do I covert the string into an array?
Is there a standard Rails way to accomplish this?
A band-aid solution would be to create a separate table. For example, you could have the model Post.has_many :pages
.
Then all you have to do it paginate through @post.pages.order("page_number ASC")
.
gem 'html_slicer'
Requires Ruby 1.9.2/1.9.3 and Rails 3 or more.
精彩评论