Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
updated the page method, added args to AR page method #276
In my fork its possible to set a default_page as a argument for the page method. If param[:page] is invalid, the page method would return the default_page and is not raising an exception, like it is now for the issue #271
params[:page] = 'foobar' posts = Post.where(:published => true).page(params[:page]) #posts.current_page = 1 # set default_page if necessary posts = Post.where(:published => true).page(params[:page], :default_page => 10) #posts.current_page = 10 # this raises no exception, it trys to return the default_page
with best regards
referenced this pull request
Nov 8, 2012
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Nope, I don't find the feature useful. The exception is deliberate so you can handle it in your application.
posts = Post.where(:published => true) begin posts = posts.page(params[:page]) rescue ArgumentError posts = posts.page(default_page) end
Or you could massage