开发者

Rails Pagination for Articles / Strings?

开发者 https://www.devze.com 2023-03-10 01:35 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消