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.

> Thanks for the code. Didn't catch the attachment at first sight. I 
> tested the plugin and it works quite fine. However, I have a small 
> problem while selecting a specific page. :page => :last always redirects 
> to the last page, even if a parameter is given. I tried to check the 
> parameter before, but this throws an error as well:
> 
> if (params[:page].nil?)
>   @replies = @bullet.replies.paginate :page => :last, :order => 
> 'created_at ASC', :per_page => 10
> else
>   @replies = @bullet.replies.paginate :page => params[:page], :order => 
> 'created_at ASC', :per_page => 10
> end
> 
> Throws:
> comparison of String with 2 failed
> 
> /Users/patrick/Sites/insight/vendor/plugins/will_paginate_last/lib/will_paginate_last/finder.rb:39:in
>  
> `>'
> /Users/patrick/Sites/insight/vendor/plugins/will_paginate_last/lib/will_paginate_last/finder.rb:39:in
>  
> `paginate'

-- 
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