Topic: Paginating Find issue.

Hi, i've been trying to get a decent paginating system to work good for a couple of days. I found PaginatingFind which is great! Although, I can't use :conditions though, which I can't understand.

  def show
   params[:page] = 1 unless params[:page] =~ /\A[0-9]+\Z/
    @words = Word.find(:all,
                     :conditions => ['user_id = ?', params[:id]],
                     :page => {
                     :size => 5,
                     :first => 1,
                     :current => params[:page]})
  end

If i remove the :size, :first and :current-bit it works perfect.

This is how i list:

    <% @words.each do |word| %>
    <li><%= word.encrypted_word %></li>
    <% end %>

How can that not be working? Isn't that: SELECT * FROM words WHERE user_id = params[:id], I don't understand why the paginater is messing things up. Anyway, i hope someone can help me because Im about to give up....

Thanks!

Edit: Link to plugin: http://cardboardrocket.com/2006/09/06/p … en-sexier/

Last edited by Emil (2006-09-08 21:12:51)

Re: Paginating Find issue.

Are you using the latest version of the plugin? Seems someone else had a similar problem. See the comments near the bottom of this page.

Edit: Oh, looks like you're using the newer parameter syntax for the plugin, so I guess that isn't the problem. Might want to contact the developer.

Last edited by ryanb (2006-09-08 21:34:15)

Railscasts - Free Ruby on Rails Screencasts

Re: Paginating Find issue.

Thanks for your answer, i got the new version. yepp! Im gonna try contact the developer as you said, thanks.

Re: Paginating Find issue.

Thanks Emil. I'm using your code and it's working ! But the problem is in my view i put :-
page <%= @wallpapers.page %> of <%= @wallpapers.page_count %>

<% if @wallpapers.previous_page? %>
<%= link_to 'previous page',
            :action => 'user',
            :page => @wallpapers.previous_page? %>
<% end %>

<% if @wallpapers.next_page? %>
<%= link_to 'next page',
            :action => 'user',
            :page => @wallpapers.next_page?%>
<% end %>


and the funny thing is when i click next button it will redirect to :-
http://127.0.0.1:3000/wallpaper/user/6?page=true. It suppose to be /wallpaper/user/6?page=2 .. 3 .. 4..

Can anyone help me to fix this thing up ? thanks

Re: Paginating Find issue.

it working! i just remove the ? at the end of next_page.!