Skip to content
This repository has been archived by the owner on Mar 20, 2018. It is now read-only.

Negative page parameter causes Internal Server Error #49

Open
ePirat opened this issue Aug 24, 2013 · 0 comments
Open

Negative page parameter causes Internal Server Error #49

ePirat opened this issue Aug 24, 2013 · 0 comments

Comments

@ePirat
Copy link

ePirat commented Aug 24, 2013

Specifying a negative value for the page GET parameter on the blog page will cause an internal server error, example:
http://schnitzelpress.org/blog/?page=-1

This can be fixed by checking in render_blog in blog.rb:

def render_blog
    total_count   = Post.latest.count
    skipped_count = (params[:page].to_i > 0) ? (params[:page].to_i * 10) : 0
    @posts = Post.latest.skip(skipped_count).limit(10)

    displayed_count = @posts.count(true)
    @show_previous_posts_button = total_count > skipped_count + displayed_count

    render_posts
end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant