hi at all I installed the plugin will_paginate successfully and now I''ll use it. But I''ve a problem. I wrote a method search and this method return an array of products. The search method is special and not an easy find query. So I can use the :conditions of the will_paginate plugin. But I will paginate the array of products. So how I can use the will_paginate plugin to group the products (:per_page => 5 products). thanks for helping... -- 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-/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 -~----------~----~----~----~------~----~------~--~---
K. R. wrote:> hi at all > I installed the plugin will_paginate successfully and now I''ll use it. > But I''ve a problem. I wrote a method search and this method return an > array of products. The search method is special and not an easy find > query. So I can use the :conditions of the will_paginate plugin. But I > will paginate the array of products. > > > So how I can use the will_paginate plugin to group the products > (:per_page => 5 products). > > thanks for helping...Here is an example of how i use will_paginate to list 20 calls from page and to change the conditions based on the restriction the user whan to give: def self.search(code,search,page) if code.blank? code="DLXACCN" end paginate :per_page=>20, :page => page, :conditions =>["#{code.upcase} like ?","%#{search}%"], :order => "DLXDAT desc" end Code is the field that the user whan to check search the value that the user is looking page is the page number And the controller look like this def current_calls @dlxcurrent_calls=DlxvcurrentCallsExt1.search(params[:code],params[:search],params[:page]) @sub_title="Detalle Llamadas Actuales" @pagetitle="Monitoreo Clientes VoIP" respond_to do |format| format.html format.xml {render :xml => @dlxcurrent_calls} end end Hope this help -- 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-/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 -~----------~----~----~----~------~----~------~--~---
But I''ve the problem, that I use acts_as_ferret for fulltext search. So I can''t use the :conditions statement in the paginate method. Because I have for example a query like ''search ruby''. So i want to find records for ''search ruby'', ''search'' and ''ruby''. So I call the find_by_content method from ferret three times. So I think, the paginate method is impractical, because I have the total_hits as recently as after the three method calls. Jesus bernardo Ruiz flores wrote:http://www.ruby-forum.com/topic/147149?reply_to=650959#postform will_paginate - Ruby Forum> Here is an example of how i use will_paginate to list 20 calls from page > and to change the conditions based on the restriction the user whan to > give: > > def self.search(code,search,page) > if code.blank? > code="DLXACCN" > end > paginate :per_page=>20, :page => page, > :conditions =>["#{code.upcase} like ?","%#{search}%"], > :order => "DLXDAT desc" > end > > Code is the field that the user whan to check > search the value that the user is looking > page is the page number > > And the controller look like this > > def current_calls > @dlxcurrent_calls=DlxvcurrentCallsExt1.search(params[:code],params[:search],params[:page]) > @sub_title="Detalle Llamadas Actuales" > @pagetitle="Monitoreo Clientes VoIP" > respond_to do |format| > format.html > format.xml {render :xml => @dlxcurrent_calls} > end > end > > Hope this help-- 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-/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 -~----------~----~----~----~------~----~------~--~---
I''m trying to get some pagination to work (I''m just starting with rails). I''m using Rails 2.0.2 (Mac OS 10.5.2). I installed the will_paginate gem, and it shows up as installed if I run ''gem list'' ... (will_paginate (2.2.1)). However, I''m getting an error anytime I try to use a paginate command like ... @articles = Article.paginate :page => params[:page] NoMethodError: undefined method `paginate'' for #<Class:0x114b7ec> I added ''require "will_paginate"'' to environment.rb, but it doesn''t seem to make any difference. What''s the secret handshake required to get pagination to work with Rails 2.0.2? Is there a tutorial somewhere that shows all the required steps to get pagination (particularly, using will_paginate) to work with 2.0.2? -lw --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It seems you haven''t installed it as a plugin, or required it in your environment. Also don''t forget to restart your webserver if you haven''t. ;-) Julian. Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #4 coming soon! http://sensei.zenunit.com/ On 14/04/2008, at 10:01 AM, lw wrote:> > I''m trying to get some pagination to work (I''m just starting with > rails). I''m using Rails 2.0.2 (Mac OS 10.5.2). I installed the > will_paginate gem, and it shows up as installed if I run ''gem > list'' ... (will_paginate (2.2.1)). > > However, I''m getting an error anytime I try to use a paginate command > like ... > > @articles = Article.paginate :page => params[:page] > > NoMethodError: undefined method `paginate'' for #<Class:0x114b7ec> > > I added ''require "will_paginate"'' to environment.rb, but it doesn''t > seem to make any difference. > > What''s the secret handshake required to get pagination to work with > Rails 2.0.2? Is there a tutorial somewhere that shows all the > required steps to get pagination (particularly, using will_paginate) > to work with 2.0.2? > > -lw > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston wrote:> It seems you haven''t installed it as a plugin, or required it in your > environment. > > Also don''t forget to restart your webserver if you haven''t. ;-) > > Julian. > > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > VIDEO #4 coming soon! > http://sensei.zenunit.com/Hi, I''ve the same error too. I have installed as a plugin and required it in my environment. But it doesn''t seems to work. I still get the NoMethodError. Can someone tell me how to solve this? Thanks -- 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-/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 -~----------~----~----~----~------~----~------~--~---
splash, I discovered what the problem was (thanks to Julian). I had installed the gem correctly. The problem was that I had put the following statement... require "will_paginate" _inside_ of "Rails::Initializer.run do |config|", rather than _following_ the end of that block. When I moved the require statement to the end of the file (app/config/environment.rb), following the ''end'' of the block, the app was able to find the gem, and that error went away. I''ve got it sort of working now. I just need to work on setting up the partial rendering correctly. -lw On Apr 13, 6:21 pm, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Julian Leviston wrote: > > It seems you haven''t installed it as a plugin, or required it in your > > environment. > > > Also don''t forget to restart your webserver if you haven''t. ;-) > > > Julian. > > > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > > VIDEO #4 coming soon! > >http://sensei.zenunit.com/ > > Hi, > > I''ve the same error too. I have installed as a plugin and required it in > my environment. But it doesn''t seems to work. I still get the > NoMethodError. Can someone tell me how to solve this? > > Thanks > -- > Posted viahttp://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-/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 -~----------~----~----~----~------~----~------~--~---