Hello - I am using paginating_find trying to paginate my records My CallsController index action is def index @calls = @current_user.calls.find(:all, :page => {:size => 4, :current => params[:page]}) end then in the index template for the calls view I have <ol> <% @current_user.calls.each do |call| %> <li><%= link_to h(call.name), :action => ''show'', :id => call %></li> <% end %> </ol> <%= @calls %> <%= paginating_links(@calls) %> I only have the <%= @calls %> to see what is in the @calls variable to see if it is available to paginating_find but it isn''t. The each.do loop gives links to all the current_user''s calls but I get no paginating. I would like 4 per page. If I change the loop to @calls.each do I get calls for all the users which is not what I want and if I change the paginating_links to paginating_links(@current_user.calls) I get the following error undefined method `page'' for #<Class:0x251dacc> Extracted source (around line #16): 13: <% end %> 14: </ol> 15: <%= @calls %> 16: <%= paginating_links(@current_user.calls) %> 17: 18: 19: So my paginating_links is getting nothing to paginate from what I can see althoug it doew list pages 1 and 2 as links Any help out there please Owen --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
alexkwolfe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-15 12:49 UTC
Re: Paginating_find Help anyone
So the problem is that @calls is not scoped to the @current_user? On Jul 14, 11:55 pm, THEBIGO <Mowenh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello - I am usingpaginating_findtrying to paginate my records My > CallsController index action is > > def index > @calls = @current_user.calls.find(:all, :page => {:size => > 4, :current => params[:page]}) > end > > then in the index template for the calls view I have > > <ol> > <% @current_user.calls.each do |call| %> > <li><%= link_to h(call.name), :action => ''show'', :id > => call %></li> > <% end %> > </ol> > <%= @calls %> > <%= paginating_links(@calls) %> > > I only have the <%= @calls %> to see what is in the @calls variable > to see if it is available topaginating_findbut it isn''t. The > each.do loop gives links to all the current_user''s calls but I get no > paginating. I would like 4 per page. If I change the loop to > @calls.each do I get calls for all the users which is not what I want > and if I change the paginating_links to > paginating_links(@current_user.calls) I get the following error > > undefined method `page'' for #<Class:0x251dacc> > > Extracted source (around line #16): > > 13: <% end %> > 14: </ol> > 15: <%= @calls %> > 16: <%= paginating_links(@current_user.calls) %> > 17: > 18: > 19: > So my paginating_links is getting nothing to paginate from what I can > see althoug it doew list pages 1 and 2 as links > Any help out there please > > Owen--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you so much for your reply Alexkwolf. Thants how I see it also When I change the line before <%paginating_links(@current_users.calls) %> to <%= @current_user.calls %> just to see what is in the variable i get the following <ol> <li><a href="/calls/142">Vanessa</a></li> <li><a href="/calls/168">Linnea</a></li> <li><a href="/calls/169">Richard</a></li> <li><a href="/calls/170">Linea</a></li> <li><a href="/calls/171">Mark</a></li> <li><a href="/calls/172">My friend</a></li> <li><a href="/calls/173">Melvin</a></li> <li><a href="/calls/174">Tuesday</a></li> <li><a href="/calls/175">Tony lynn</a></li> <li><a href="/calls/176">Lyn Lyn</a></li> <li><a href="/calls/177">Marjorie</a></li> </ol> #<Call:0x20f4b44>#<Call:0x20f4a54>#<Call:0x20f4950>#<Call: 0x20f4874>#<Call:0x20f4798>#<Call:0x20f46a8>#<Call:0x20f45b8>#<Call: 0x20f44c8>#<Call:0x20f43ec>#<Call:0x20f4310>#<Call:0x20f4234> 1 <a href="/calls?page=2">2</a> <a href="/calls?page=3">3</a> and if I change the line before to just <%= @calls %> i get this avter the loop output </ol> #<PagingEnumerator:0x264d5c8> 1 <a href="/calls?page=2">2</a> <a href="/calls?page=3">3</a> So I am not sure what is happening allthough both times I get this interesting output of numbers. Any idea would be greatly appreciated Owen On Jul 15, 5:49 am, "alexkwo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <alexkwo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So the problem is that @calls is not scoped to the @current_user? > > On Jul 14, 11:55 pm, THEBIGO <Mowenh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello - I am usingpaginating_findtrying to paginate my records My > > CallsController index action is > > > def index > > @calls = @current_user.calls.find(:all, :page => {:size => > > 4, :current => params[:page]}) > > end > > > then in the index template for the calls view I have > > > <ol> > > <% @current_user.calls.each do |call| %> > > <li><%= link_to h(call.name), :action => ''show'', :id > > => call %></li> > > <% end %> > > </ol> > > <%= @calls %> > > <%= paginating_links(@calls) %> > > > I only have the <%= @calls %> to see what is in the @calls variable > > to see if it is available topaginating_findbut it isn''t. The > > each.do loop gives links to all the current_user''s calls but I get no > > paginating. I would like 4 per page. If I change the loop to > > @calls.each do I get calls for all the users which is not what I want > > and if I change the paginating_links to > > paginating_links(@current_user.calls) I get the following error > > > undefined method `page'' for #<Class:0x251dacc> > > > Extracted source (around line #16): > > > 13: <% end %> > > 14: </ol> > > 15: <%= @calls %> > > 16: <%= paginating_links(@current_user.calls) %> > > 17: > > 18: > > 19: > > So my paginating_links is getting nothing to paginate from what I can > > see althoug it doew list pages 1 and 2 as links > > Any help out there please > > > Owen--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think I may have figured it out In my index.rhtml for app/views/calls I tried this code <% @recent_calls = @current_user.calls.find(:all, :page => {:size => 4, :current => params[:page]}) %> <ol> <% @recent_calls.each do |c| %> <li><%= link_to h(c.name), :action => ''show'', :id => c.id %></li> <% end %> </ol> <%= paginating_links(@recent_calls) %> and it gave me only the 10 calls associated with the current_user so I have to try a few more things and I want to have a previous link and a next link so I don''t have to click on the page numbers. So thanks for the interest and help and thanks to alex wolf for the plug in for paginating_links that works for me On Jul 15, 6:26 am, THEBIGO <Mowenh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you so much for your reply Alexkwolf. Thants how I see it also > When I change the line before <%> paginating_links(@current_users.calls) %> > to <%= @current_user.calls %> just to see what is in the variable i > get the following > > <ol> > > <li><a href="/calls/142">Vanessa</a></li> > > <li><a href="/calls/168">Linnea</a></li> > > <li><a href="/calls/169">Richard</a></li> > > <li><a href="/calls/170">Linea</a></li> > > <li><a href="/calls/171">Mark</a></li> > > <li><a href="/calls/172">My friend</a></li> > > <li><a href="/calls/173">Melvin</a></li> > > <li><a href="/calls/174">Tuesday</a></li> > > <li><a href="/calls/175">Tony lynn</a></li> > > <li><a href="/calls/176">Lyn Lyn</a></li> > > <li><a href="/calls/177">Marjorie</a></li> > > </ol> > #<Call:0x20f4b44>#<Call:0x20f4a54>#<Call:0x20f4950>#<Call: > 0x20f4874>#<Call:0x20f4798>#<Call:0x20f46a8>#<Call:0x20f45b8>#<Call: > 0x20f44c8>#<Call:0x20f43ec>#<Call:0x20f4310>#<Call:0x20f4234> > > 1 <a href="/calls?page=2">2</a> <a href="/calls?page=3">3</a> > > and if I change the line before to just <%= @calls %> i get > this avter the loop output > > </ol> > #<PagingEnumerator:0x264d5c8> > > 1 <a href="/calls?page=2">2</a> <a href="/calls?page=3">3</a> > > So I am not sure what is happening allthough both times I get this > interesting output of numbers. Any idea would be greatly appreciated > > Owen > > On Jul 15, 5:49 am, "alexkwo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <alexkwo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > So the problem is that @calls is not scoped to the @current_user? > > > On Jul 14, 11:55 pm, THEBIGO <Mowenh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello - I am usingpaginating_findtrying to paginate my records My > > > CallsController index action is > > > > def index > > > @calls = @current_user.calls.find(:all, :page => {:size => > > > 4, :current => params[:page]}) > > > end > > > > then in the index template for the calls view I have > > > > <ol> > > > <% @current_user.calls.each do |call| %> > > > <li><%= link_to h(call.name), :action => ''show'', :id > > > => call %></li> > > > <% end %> > > > </ol> > > > <%= @calls %> > > > <%= paginating_links(@calls) %> > > > > I only have the <%= @calls %> to see what is in the @calls variable > > > to see if it is available topaginating_findbut it isn''t. The > > > each.do loop gives links to all the current_user''s calls but I get no > > > paginating. I would like 4 per page. If I change the loop to > > > @calls.each do I get calls for all the users which is not what I want > > > and if I change the paginating_links to > > > paginating_links(@current_user.calls) I get the following error > > > > undefined method `page'' for #<Class:0x251dacc> > > > > Extracted source (around line #16): > > > > 13: <% end %> > > > 14: </ol> > > > 15: <%= @calls %> > > > 16: <%= paginating_links(@current_user.calls) %> > > > 17: > > > 18: > > > 19: > > > So my paginating_links is getting nothing to paginate from what I can > > > see althoug it doew list pages 1 and 2 as links > > > Any help out there please > > > > Owen--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---