开发者

how to use a max or ceiling in Ruby?

I have a pag开发者_JAVA技巧inator that shows the following for page 1

records 1 through 10

10 being the number of records per page. Thing is for new users they might have under 10 records so showing 10 as the # per page doesn't work

How can I do something like this

if total_record_count is < 10, show total_record_count ELSE show 10 (records per page)

Thanks


Well there's always Enumerable#min:

<%= [posts.count, 10].min %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜