Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Why is :page required? #18

Closed
richievos opened this Issue · 4 comments

3 participants

@richievos

If the :page variable is nil it defaults to 1. Yet you're still required to pass it.

Why is this? Not passing any judgement either way, just seems like a weird api.

I'm going to monkey-patch mine to not do this, but am wondering if there's something I'm missing.

@chriseppstein

I've had this thought a couple times now. But then I remember that nil means that :page => params[:page] was passed and there was no page parameter to the url. But no :page parameter at all probably means I forgot it. Certainly there are cases where this isn't true, but I think this is a little defensive programming that has saved countless cumulative hours of debugging.

@richievos

That's what I assumed it was for (the defensive programming thing), but still feels kind of weird to me. Maybe it's one of those things where a config var should toggle it, or a config var should set the default.

I'd be happy to build either if anyone else think's that's useful.

@richievos

Btw, by default I meant something like:
raise "defensive" if no page argument passed && WillPaginate.default_page.nil?

@mislav
Owner

Chris is right. As for the proposed configuration variable: I only add configuration options for features I expect widespread usage of, and I don't want widespread usage of hardcoding ":page" to "1".

Advanced users can set their own behavior by overriding WP::Collection or creating helper methods that wrap #paginate or other methods.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.