PP Junty wrote:
> you should use blank? instead of nil? because even the original
> will_paginate will throw an error if you pass an empty string.
> and you should not rely on what you receive in the param :page as
> a user could manually alter the url to some strange value. what
> i do is to have a parse method that ensure that will_paginate is
> getting a valid page number, that is why i didn't bother throwing
> a more informative error message, i'll see if it can be improved.

I solved the problem with a simple integer validation:

@page = params[:page].to_i
if (@page != 0)
  @replies = @bullet.replies.paginate :page => @page, :order => 
'created_at ASC', :per_page => 10
else
  @replies = @bullet.replies.paginate :page => :last, :order => 
'created_at ASC', :per_page => 10
end

Works pretty good.

Thank you for this enhancement to will_paginate. You should definitely 
put it to github.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to