Hi, I am trying pagination with using the plug-in: will_paginate. Here is my code, I got a scaffold model named "post". in posts_controller.rb: I insert the following code in the index method def index ... @posts = Post.paginate :page => params[:page], :per_page => 3 ... end in posts/index.html.erb I insert the the following code at the bottom of file <%= will_paginate @posts %> Then I run it, but got the following error message. What I missed?? NoMethodError in Posts#index Showing posts/index.html.erb where line # raised: protected method `url_for'' called for #<WillPaginate::LinkRenderer: 0xc8ec7e> The will_paginate version of mine is: 2.2.1 I think to use the pagination mechanism provided by will_paginate should be easy. Could somebody give me a guide? Thanks! firestoke --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try this in your controller: @posts = Post.paginate(:all, :page => params[:page], :per_page => 3) The paginate method acts the same as find, so you usually will need to specify either :all or :first. If that doesn''t do it, paste your full error. -Kyle On Apr 16, 11:45 pm, FireStoke <davidhung...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, I am trying pagination with using the plug-in: will_paginate. > Here is my code, I got a scaffold model named "post". > > in posts_controller.rb: > I insert the following code in the index method > > def index > ... > @posts = Post.paginate :page => params[:page], :per_page => 3 > ... > end > > in posts/index.html.erb > I insert the the following code at the bottom of file > > <%= will_paginate @posts %> > > Then I run it, but got the following error message. What I missed?? > > NoMethodError in Posts#index > > Showing posts/index.html.erb where line # raised: > > protected method `url_for'' called for #<WillPaginate::LinkRenderer: > 0xc8ec7e> > > The will_paginate version of mine is: 2.2.1 > I think to use the pagination mechanism provided by will_paginate > should be easy. > Could somebody give me a guide? Thanks! > > firestoke--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
FireStoke
2008-Apr-18 05:33 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
I try it, but it still doesn''t work. Here is the full error trace log: ------------------------------------------------------------------------------------------------------------------------ NoMethodError in Posts#index Showing posts/index.html.erb where line # raised: protected method `url_for'' called for #<WillPaginate::LinkRenderer: 0x1ed3030> Extracted source (around line #): RAILS_ROOT: D:/InstantRails-2.0-win/rails_apps/ApmKm Application Trace | Framework Trace | Full Trace D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:250:in `page_link_or_span'' D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:212:in `windowed_links'' D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:209:in `each'' D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:209:in `inject'' D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:209:in `windowed_links'' D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:175:in `to_html'' D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:98:in `will_paginate'' app/views/posts/index.html.erb:25:in `_run_erb_47app47views47posts47index46html46erb'' app/controllers/posts_controller.rb:11:in `index'' :1:in `start'' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Is it really not giving you line numbers in the errors? What is on line 25 of your index.html.erb? Line 11 in your controller? It could be something strange regarding Instant Rails. -Kyle On Apr 18, 12:33 am, FireStoke <davidhung...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I try it, but it still doesn''t work. > Here is the full error trace log: > ------------------------------------------------------------------------------------------------------------------------ > NoMethodError in Posts#index > > Showing posts/index.html.erb where line # raised: > > protected method `url_for'' called for #<WillPaginate::LinkRenderer: > 0x1ed3030> > > Extracted source (around line #): > > RAILS_ROOT: D:/InstantRails-2.0-win/rails_apps/ApmKm > Application Trace | Framework Trace | Full Trace > > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:250:in > `page_link_or_span'' > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:212:in > `windowed_links'' > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:209:in `each'' > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:209:in `inject'' > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:209:in > `windowed_links'' > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:175:in `to_html'' > D:/NetBeans 6.1 RC1/ruby2/jruby-1.1/lib/ruby/gems/1.8/gems/ > will_paginate-2.2.1/lib/will_paginate/view_helpers.rb:98:in > `will_paginate'' > app/views/posts/index.html.erb:25:in > `_run_erb_47app47views47posts47index46html46erb'' > app/controllers/posts_controller.rb:11:in `index'' > :1:in `start''--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
firestoke
2008-Apr-20 04:52 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
The line 25 of index.html.erb is: <%= will_paginate @posts %> And the line 11 of the controller should be: respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } end But If I remove the line 11 in the controller The error still occurs. It''s really a strange error. Maybe I miss some gems? But I do install the will_paginate plug-in completely. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Apr-20 06:56 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
firestoke wrote:> The line 25 of index.html.erb is: > <%= will_paginate @posts %> >TRY To COMMENT THEM : # respond_to do |format| # format.html # index.html.erb # format.xml { render :xml => @posts } # end here is to option for @posts: [1] @posts = Post.paginate :page => params[:page], :per_page => 3 [2] @posts = paginate :posts, :page => params[:page], :per_page => 3 let me know what happen. Reinhart http://teapoci.blogspot.com -- 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 -~----------~----~----~----~------~----~------~--~---
firestoke
2008-Apr-20 10:44 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
ya, I mark it but result is the same. After tried many times, I found this error only occurs when launch it from Netbeans WEBrick(press F6 to run main project). If I launch it by the Mongrel provided by Instant Rails, then it works just fine!! But I still don''t know what the root cause is, very strange and mysterious..... just like Titanic.... Orz firestoke --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Apr-20 11:26 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
I have tons of trouble in implementing my rails application trough NetBeans, so that I prefer to use RoRED, Instant Rails or SCITE to run rails server than NetBean unless it''s only for editor. Reinhart http://teapoci.blogspot.com -- 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 -~----------~----~----~----~------~----~------~--~---
Anas Ali
2008-Apr-20 12:31 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
hi im anas to use will_paginate u have 2 install will_paginate gem... and u wrote the code in controller is correct... but in view(i.e. in index) we''ve to define <%= will_paginate @posts %> in very first line.......... i hope this will solve ur problem....... -- 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 -~----------~----~----~----~------~----~------~--~---
FireStoke
2008-Apr-21 02:44 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
I do install will_paginate gem both in Netbeans and Instant Rails. (because they got their own ruby interpreter) And the code I write at the first post is just fine. I didn''t change them at all and just launch by Mongrel, then it works without any error. So I think the position of <%= will_paginate @posts %> in view file should be problem. On 4月20日, 下午8時31分, Anas Ali <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hi im anas > > to use will_paginate u have 2 install will_paginate gem... > and u wrote the code in controller is correct... > but in view(i.e. in index) we''ve to define <%= will_paginate @posts %> > in very first line.......... > i hope this will solve ur problem....... > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
pepa007
2008-Jun-02 19:53 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
It''s a NetBeans bug, had the same problem. just run the server from console, not from netbeans, and it should work (did for me) also managed to google out a patch http://jira.codehaus.org/browse/JRUBY-2418 but haven''t tried it yet I''m currently using NetBeans as an editor only :-) It can do almost everything like textmate/E but it''s free (no cash to buy E so far, saving money for MacBook Air :-)) On 21 Dub, 04:44, FireStoke <davidhung...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I do install will_paginate gem both in Netbeans and Instant Rails. > (because they got their own ruby interpreter) > And the code I write at the first post is just fine. I didn''t change > them at all and just launch by Mongrel, then it works without any > error. > So I think the position of <%= will_paginate @posts %> in view file > should be problem. > > On 4月20日, 下午8時31分, Anas Ali <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > hi im anas > > > to use will_paginate u have 2 install will_paginate gem... > > and u wrote the code in controller is correct... > > but in view(i.e. in index) we''ve to define <%= will_paginate @posts %> > > in very first line.......... > > i hope this will solve ur problem....... > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Erno Mononen
2008-Jun-13 14:18 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
On 02/06/2008, pepa007 <richter.josef-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > It''s a NetBeans bug, had the same problem.Actually I think it is a JRuby bug, not NetBeans. You can always use native Ruby (MRI) in NetBeans instead of JRuby, just set the platform to Ruby in your project properties (right click the project node -> properties -> ruby platform). If you don''t see native Ruby listed there you can add it by clicking the manage button next to the platform combo box. In any case the issue has been fixed in JRuby 1.1.2, which was released a while ago. HTH, Erno --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Birgit (Westhawk)
2008-Jul-03 14:51 UTC
Re: Occurred url_for ERROR mesasge while using will_paginate
Hi, I stumbled on the same problem, and I''m using NetBeans (6.1), JRuby (1.1), Rails (2.0.2) (etc, etc) as well. The problem when away after editing the will_paginate view_helpers.rb file, that (for me) lives in ~/.netbeans/6.1/jruby-1.1/lib/ruby/gems/1.8/gems/will_paginate-2.2.2/ lib/will_paginate/ and making the method "def url_for(page)" public by moving it above the "protected" statement. You have to restart the Webrick process. Cheers, Birgit --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---