will_paginate

91 views
Skip to first unread message

Jeff Chen

unread,
Aug 24, 2010, 3:36:49 AM8/24/10
to Ruby on Rails: Talk
Dear Madam/ Sir,

This is my first post, and I am stuck it for many months.

I have below error msg:

NoMethodError (undefined method `paginate' for #<Class:0x640ccc4>):
app/controllers/manage_controller.rb:24:in `list'

Here is my code:

def list

#@images = Image.paginate :page => params[:page], :per_page => 5
@items = Item.paginate :page => params[:page], :per_page => 5
#@items = Item.paginate(:page => params[:page], :per_page => 10)
#@user_pages, @users = paginate ( :users, :per_page => 5 )
#@babysitters = Babysitter.cached(:list).paginate(:page =>
params[:page],:per_page => 10)
# :per_page => 10, :order => 'created_at
DESC'
#@users = User.paginate(:page => params[:page])
#@items = Item.paginate(:page => params[:page])
#@items = Item.paginate(:page => params[:page], :per_page => 5)
#@careers = Career.paginate :page => params[:page], :per_page =>
10


end

I did add require 'will_paginate' after the end of environment.rb,
what else I can do now?

Thanks and Best Regards,
Jeff

Frederick Cheung

unread,
Aug 24, 2010, 4:01:57 AM8/24/10
to Ruby on Rails: Talk
Don't do that - use config.gem to load gems (in 2,x that is - look at
bundler if you are using rails 3)

Fred

Jeff Chen

unread,
Aug 25, 2010, 5:42:53 AM8/25/10
to Ruby on Rails: Talk
Dear

On 8月24日, 下午4時01分, Frederick Cheung <frederick.che...@gmail.com>
wrote:
I write the config.gem 'will_paginate' in the inside of
environment.rb, but got below error msg:

undefined local variable or method 'config' for main Object
<NameError>

How to fix it? Thanks.

Frederick Cheung

unread,
Aug 25, 2010, 5:58:38 AM8/25/10
to rubyonra...@googlegroups.com, Ruby on Rails: Talk

On 25 Aug 2010, at 10:42, Jeff Chen <jeffch...@gmail.com> wrote:

>>
>>
>
> I write the config.gem 'will_paginate' in the inside of
> environment.rb, but got below error msg:
>
> undefined local variable or method 'config' for main Object
> <NameError>
>
> How to fix it? Thanks.
>

You're probably putting it in the wrong place. What does your environment.rb look like

Fred
> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>

Jeff Chen

unread,
Aug 25, 2010, 10:58:17 PM8/25/10
to Ruby on Rails: Talk
Yes, I put it before the end, then the <NameError> is passed.

But the undefined method `paginate' for #<Class:0x6782980> is happened
again.

On 8月25日, 下午5時58分, Frederick Cheung <frederick.che...@gmail.com>
wrote:

Raony Vieira ferreira

unread,
Aug 26, 2010, 11:01:09 AM8/26/10
to rubyonra...@googlegroups.com
Hello Guys
I hope someone can help me
I've been trying but without success to do a pagination using the
will_paginate gem.
When I'm listing all records the system paginates but when I'm doing a
filter to show some records, just show the first five. Someone knows
whats happening?

My code


CONTROLLER

def index

@contract = Contract.new(params[:contract])
page = (params[:page] ||= 1).to_i
@contracts = Contract.search_index({:page => page})
@legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
NM_PESSOA", :joins => [:person])

@persons = Person.all

respond_to do |format|
format.html # index.html.erb
end
end


def list

@contract = Contract.new(params[:contract])
page = (params[:page] ||= 1).to_i
@contracts = Contract.find_by_params(params[:contract])
@legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
NM_PESSOA", :joins => [:person])

@person = Person.all
render :index

end


VIEW
<% form_for(@contract, :url => { :action => "list"}, :onKeyPress =>
"submit();" ) do |f| %>
<!-- Início da Tabela de Filtro -->

<table class="Cabecalho" border="0">
<thead>
<tr>
<td colspan="4" class="titulos">Empresa:<br/>
<%= select(:contract, :CD_PESSOA_JURIDICA,
@legal_entities.collect{ |p| [
p.NM_PESSOA, p.CD_PESSOA_JURIDICA]},
{ :include_blank => true }) %>
</td>
</tr>
<tr>
<td width="30%" class="titulos">Número do contrato:<br/>
<%= f.text_field(:CD_CONTRATO, :style=>"width: 90%;",
:maxlength=>"7", :onKeypress => "apenasnum(this);")%>
</td>
<td width="20%"class="titulos">Ano:<br/>
<%= f.text_field(:NO_ANO, :style=>"width: 90%;", :onKeypress =>
"apenasnum(this);")%>
</td>
<td width="40%"class="titulos">Objeto do contrato:<br/>
<%= f.text_field(:DS_OBJETO_CONTRATO, :style=>"width: 80%;",
:onKeypress => "apenastex(this);")%>
</td>
<td width="9%" align="right" style="padding-right:35px;">
<%= image_submit_tag("lupa.png", :title => "Pesquisar")%>
</td>
</tr>
</thead>
</table>

<br/>

<div class="tab_botao">
<%= link_to ( image_tag("incluir.jpg",:style=>"width: 16px;
heigth:16px; border:0", :title =>"Incluir Novo"))+' Incluir Novo',
new_contract_path %>
</div>


<% if @contracts.empty? %>
<div class="div_registro">
<p>Nemhum contrato foi encontrado</p>
</div>
<% else %>

<table cellpadding="0" cellspacing="1" class="Cabecalho">
<thead>
<tr class="Cabecalho_bg">
<th align="left" style="padding-left: 5px;">Numero Contrato</th>
<th align="left" style="padding-left: 5px;">Ano</th>
<th align="left" style="padding-left: 5px;">Empresa</th>
<th align="left" style="padding-left: 5px;">Objeto</th>
<th align="left" style="padding-left: 5px;">Termo Aditivo</th>
</tr>
</thead>

<tbody class="zebra">
<% @contracts.each do |contract| %>
<tr>
<td style="padding-left:5px;"><%= link_to
contract.CD_CONTRATO, contract %></td>
<td style="padding-left:5px;"><%= contract.NO_ANO %></td>
<td style="padding-left:5px;" ><%=
contract.legal_entity.person.NM_PESSOA %></td>
<td style="padding-left:5px;"><%=
contract.DS_OBJETO_CONTRATO %></td>
<td style="padding-left:5px;"><b><%=
"#{contract.additiv_contracts.size} aditivos" %></b></td>
</tr>
<% end %>
</tbody>
<tr class="Cabecalho_bg">
<td colspan="6" class="Result">
Total de <b><%= @contracts.total_entries %></b> &iacute;tens.
</td>
</tr>

<tr>
<td colspan="6" class="paginacao">
<%= will_paginate @contracts %>

</td>
</tr>
</table>
<% end %>
<% end %>


Cheers
--
Posted via http://www.ruby-forum.com/.

Ar Chron

unread,
Aug 26, 2010, 3:45:15 PM8/26/10
to rubyonra...@googlegroups.com
Raony Vieira ferreira wrote:
> CONTROLLER
>
> def index
> @contract = Contract.new(params[:contract])
> page = (params[:page] ||= 1).to_i
> @contracts = Contract.search_index({:page => page})
> @legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
> NM_PESSOA", :joins => [:person])
> @persons = Person.all
> respond_to do |format|
> format.html # index.html.erb
> end
> end
>
>
> def list
> @contract = Contract.new(params[:contract])
> page = (params[:page] ||= 1).to_i
> @contracts = Contract.find_by_params(params[:contract])
> @legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
> NM_PESSOA", :joins => [:person])
> @person = Person.all
> render :index
> end

Seems like this should all be controller work (well, not quite, and this
is based on the mislav-will_paginate gem)...

You could use a generic
@contracts = Contract.paginate :conditions => cond, :page =>
params[:page]

where cond is your scoping criteria, such as:

cond = ['name LIKE ?', some_params_entry] or
cond = ['1=1'] for the everything case

The only difference in your two methods is the Contract.find...

Not knowing what the search_index or find_by_params methods do
precisely, could you create a single build_conditions method in the
Contract model that returns 'cond' and covers all your search cases to
simplify your logic?

index and list are awfully similar... do you need both?

Raony Vieira ferreira

unread,
Aug 26, 2010, 4:08:08 PM8/26/10
to rubyonra...@googlegroups.com

>
> The only difference in your two methods is the Contract.find...
>
> Not knowing what the search_index or find_by_params methods do
> precisely, could you create a single build_conditions method in the
> Contract model that returns 'cond' and covers all your search cases to
> simplify your logic?
>
> index and list are awfully similar... do you need both?

I don't need both, I tried but I had no success using generic
I think I've done something wrong in model.
Using generic i have to modify my model?
I'm quite confused with that, because I usually use will_paginate
without filter.

Cheers

Ar Chron

unread,
Aug 26, 2010, 5:39:58 PM8/26/10
to rubyonra...@googlegroups.com
Raony Vieira ferreira wrote:
> I don't need both, I tried but I had no success using generic
> I think I've done something wrong in model.

Skinny controllers, fat models.

Given scoping criteria that may be coming in params, the model should
know how to respond to those params for limiting return sets, and can
adapt its 'cond' to account for those. Controller just knows to use the
received cond in its paginate call.

Model:

class Contract
def build_conditions(params)
# the default returns
cond = ['1=1']


page = (params[:page] ||= 1).to_i

per_page = 15
if params[:partial_contract_name]
# return a scoping condition here, this can be as complex
# as you want/require
cond = ['name LIKE ?%', params[:partial_contract_name]
end
return cond, page, per_page
end
end

Controller:

def index
@contract = Contract.new(params[:contract])

cond, page, per_page = @contract.build_conditions(params)
@contracts = Contract.paginate :conditions => cond, :page => page,
:per_page => per_page


@legal_entities = LegalEntity.all(:select => "CD_PESSOA_JURIDICA,
NM_PESSOA", :joins => [:person])
@persons = Person.all
respond_to do |format|
format.html # index.html.erb
end
end

should be a nice generic implementation using will_paginate. Again, I
don't know what was happening in your search_index or find_by_params
methods.

Jeff Chen

unread,
Aug 27, 2010, 11:06:33 AM8/27/10
to Ruby on Rails: Talk
I need help.

I input gem 'will_paginate' or config.gem 'will_paginate'

but got the undefined method `paginate' for #<Class:0x653996c>

On 8月26日, 下午11時01分, Raony Vieira ferreira <li...@ruby-forum.com>
wrote:

Raony Vieira ferreira

unread,
Aug 27, 2010, 12:05:16 PM8/27/10
to rubyonra...@googlegroups.com
Jeff Chen wrote:
> I need help.
>
> I input gem 'will_paginate' or config.gem 'will_paginate'
>
> but got the undefined method `paginate' for #<Class:0x653996c>
>
> On 8月26日, 下午11時01分, Raony Vieira ferreira <li...@ruby-forum.com>


The correct way is config.gem 'will_paginate'
but if the will_paginate is already installed should have worked.

Jeff Chen

unread,
Aug 28, 2010, 10:44:05 PM8/28/10
to Ruby on Rails: Talk
Thanks.

But I config.gem 'will_paginate' before the end of environment.rb and
f the will_paginate is already installed but not worked. Got the
undefined method `paginate' for #<Class:0x653996c> Why? May you give
me a hint, or sample, let me fix it up.

On 8月28日, 上午12時05分, Raony Vieira ferreira <li...@ruby-forum.com>
wrote:

Colin Law

unread,
Aug 29, 2010, 3:35:28 AM8/29/10
to rubyonra...@googlegroups.com
On 29 August 2010 03:44, Jeff Chen <jeffch...@gmail.com> wrote:
> Thanks.
>
> But I config.gem 'will_paginate' before the end of environment.rb and
> f the will_paginate is already installed but not worked.  Got the
> undefined method `paginate' for #<Class:0x653996c> Why? May you give
> me a hint, or sample, let me fix it up.

config.gem must go inside the initializer.run block, not just before the end.

Post your environment.rb if you think you have it correctly, also the output of
gem list --local
and the full error that you are getting.

Colin

Jeff Chen

unread,
Aug 29, 2010, 8:10:59 AM8/29/10
to Ruby on Rails: Talk
Dear Colin,

Thanks.

1. The environment.rb:

RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default
configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those
specified here.
# Application configuration should go into files in config/
initializers
# -- all .rb files in that directory are automatically loaded.
config.gem 'will_paginate'
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )

# Specify gems that this application depends on and have them
installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://
code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"

# Only load the plugins named here, in the order given (default is
alphabetical).
# :all can be used as a placeholder for all plugins not explicitly
named
# config.plugins =
[ :exception_notification, :ssl_requirement, :all ]

# Skip frameworks you're not going to use. To use Rails without a
database,
# you must remove the Active Record framework.
# config.frameworks -=
[ :active_record, :active_resource, :action_mailer ]

# Activate observers that should always be running
# config.active_record.observers
= :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record
auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone
names.
config.time_zone = 'UTC'

# The default locale is :en and all translations from config/locales/
*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.
{rb,yml}')]
# config.i18n.default_locale = :de

end

2. The output of gem list --local:
will_paginate <2.3.14>

3. The full error MSG:
NoMethodError in ManageController#index

undefined method `paginate' for #<Class:0x679f940>


On 8月29日, 下午3時35分, Colin Law <clan...@googlemail.com> wrote:

Colin Law

unread,
Aug 29, 2010, 8:40:32 AM8/29/10
to rubyonra...@googlegroups.com
On 29 August 2010 13:10, Jeff Chen <jeffch...@gmail.com> wrote:

Please don't top post it makes it more difficult to follow the thread Thanks
>...

That looks OK. When you run script/server I presume you do not get an
error about missing gems? Or any other error?

>
> 2. The output of  gem list --local:
> will_paginate <2.3.14>

OK

>
> 3. The full error MSG:
>  NoMethodError in ManageController#index
>
> undefined method `paginate' for #<Class:0x679f940>

What is the path and filename of that controller? Can you post the
code for the index method?

Colin

Jeff Chen

unread,
Aug 29, 2010, 6:44:03 PM8/29/10
to Ruby on Rails: Talk
The manage_c0ntroller.rb:

class ManageController < ApplicationController

def index
list
render :action => 'list'
end

# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }


def list


@items = Item.paginate(:page => params[:page], :per_page => 10)


end
#@posts = Post.paginate :page => params[:page], :per_page => 50
def show
@item = Item.find(params[:id])
end

def new
@item = Item.new
end

def create
@item = Item.new(params[:item])
if @item.save
flash[:notice] = 'Item was successfully created.'
redirect_to :action => 'list'
else
render :action => 'new'
end
end

def edit
@item = Item.find(params[:id])
end

def update
@item = Item.find(params[:id])
if @item.update_attributes(params[:item])
flash[:notice] = 'Item was successfully updated.'
redirect_to :action => 'show', :id => @item
else
render :action => 'edit'
end
end

def destroy
Item.find(params[:id]).destroy
redirect_to :action => 'list'
end
end


On 8月29日, 下午8時40分, Colin Law <clan...@googlemail.com> wrote:

Colin Law

unread,
Aug 30, 2010, 4:08:01 AM8/30/10
to rubyonra...@googlegroups.com
On 29 August 2010 23:44, Jeff Chen <jeffch...@gmail.com> wrote:
> The manage_c0ntroller.rb:

Did you note the first request in my previous email - not to top post?
That means not to post your new message before the quotes of the
previous message, but to insert your reply into the previous message.
Now I have scroll up and down this email looking at what I asked and
back up to see your response. It also makes it less likely that you
will forget to answer a question.

In particular you have not confirmed that you do not get any errors
when you start the server.

Also please can you confirm that if you remove the calls to paginate
and just fetch all records that all works as expected.

Further comments below.

>
> class ManageController < ApplicationController
>
>  def index
>    list
>    render :action => 'list'
>  end

Again I am having to cut and paste from below, if you had not top
posted I would not have had to do this. You previously said the error
is


>> > NoMethodError in ManageController#index
>> > undefined method `paginate' for #<Class:0x679f940>

I don't see any call to paginate so that is a bit odd. Please confirm
exactly what is happening and make sure the code you post matches the
error message. Post the full error trace for the message please.

And once again please don't top post.

Colin

Jeff Chen

unread,
Aug 30, 2010, 6:10:55 AM8/30/10
to Ruby on Rails: Talk


On 8月30日, 下午4時08分, Colin Law <clan...@googlemail.com> wrote:
> On 29 August 2010 23:44, Jeff Chen <jeffchen1...@gmail.com> wrote:
>
> > The manage_c0ntroller.rb:
>
> Did you note the first request in my previous email - not to top post?
>  That means not to post your new message before the quotes of the
> previous message, but to insert your reply into the previous message.
> Now I have scroll up and down this email looking at what I asked and
> back up to see your response.  It also makes it less likely that you
> will forget to answer a question.
>
> In particular you have not confirmed that you do not get any errors
> when you start the server.

Yes, confirm there is no any errors when start the server

>
> Also please can you confirm that if you remove the calls to paginate
> and just fetch all records that all works as expected.

Yes, all works when remove call to paginate

>
> Further comments below.
>
>
>
> > class ManageController < ApplicationController
>
> >  def index
> >    list
> >    render :action => 'list'
> >  end
>
> Again I am having to cut and paste from below, if you had not top
> posted I would not have had to do this.  You previously said the error
> is
>
> >> >  NoMethodError in ManageController#index
> >> > undefined method `paginate' for #<Class:0x679f940>
>
> I don't see any call to paginate so that is a bit odd.  Please confirm
> exactly what is happening and make sure the code you post matches the
> error message.  Post the full error trace for the message please.

Here is the development.log:
Processing ManageController#index (for 127.0.0.1 at 2010-08-30
17:30:14) [GET]
[4;35;1mSQL (64.0ms) [0m [0mSHOW TABLES [0m
[4;36;1mItem Columns (403.0ms) [0m [0;1mSHOW FIELDS FROM
`items` [0m

NoMethodError (undefined method `paginate' for #<Class:0x675f980>):
app/controllers/manage_controller.rb:25:in `list'
app/controllers/manage_controller.rb:4:in `index'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendered rescues/_trace (144.0ms)
Rendered rescues/_request_and_response (8.0ms)
Rendering rescues/layout (internal_server_error)

>
> And once again please don't top post.

Hope the post is correct this time. Thanks.

>
> Colin

Raony Vieira ferreira

unread,
Aug 30, 2010, 7:30:04 AM8/30/10
to rubyonra...@googlegroups.com

> NoMethodError (undefined method `paginate' for #<Class:0x675f980>):
> app/controllers/manage_controller.rb:25:in `list'
> app/controllers/manage_controller.rb:4:in `index'
> c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
> c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
> c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
>
> Rendered rescues/_trace (144.0ms)
> Rendered rescues/_request_and_response (8.0ms)
> Rendering rescues/layout (internal_server_error)


I don't know but try, check the will_paginate version and write in
evironment.rb between the "Rails::Initializer.run do |config|" and the
last end this

config.gem 'will_paginate', :version => 'your version'

and restart the server and check

Colin Law

unread,
Aug 30, 2010, 8:19:42 AM8/30/10
to rubyonra...@googlegroups.com
On 30 August 2010 10:33, Jeff Chen <jeffch...@gmail.com> wrote:
>
>
> On 8月30日, 下午4時08分, Colin Law <clan...@googlemail.com> wrote:
>> ...

>> In particular you have not confirmed that you do not get any errors
>> when you start the server.
>
> Yes, I get not any errors when start the server.

>>
>> Also please can you confirm that if you remove the calls to paginate
>> and just fetch all records that all works as expected.
>
> Yes, I did remove the calls to paginate, and just fetch all records

> that all works as expected.
>>
>> ...

>> I don't see any call to paginate so that is a bit odd.  Please confirm
>> exactly what is happening and make sure the code you post matches the
>> error message.  Post the full error trace for the message please.
>
> Processing ManageController#index (for 127.0.0.1 at 2010-08-30
> 17:30:14) [GET]
>   [4;35;1mSQL (64.0ms) [0m    [0mSHOW TABLES [0m
>   [4;36;1mItem Columns (403.0ms) [0m    [0;1mSHOW FIELDS FROM
> `items` [0m
>
> NoMethodError (undefined method `paginate' for #<Class:0x675f980>):
>  app/controllers/manage_controller.rb:25:in `list'

Right so the error is in list, that is why I asked for the whole error message.

>  app/controllers/manage_controller.rb:4:in `index'
>  c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
>  c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
>  c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
>

I see that the error is from Item.paginate. You have not told us
anything about the Item class. Can you show us the code for that
class (delete methods that are not relevant before posting) and
confirm the path and filename to that class.

I am running out of ideas however.

Colin

Jeff Chen

unread,
Aug 30, 2010, 9:34:05 PM8/30/10
to Ruby on Rails: Talk
1. Checking the version:
gem list -- local -> will_paginate <2.3.14>

2. and I add below code into environment:

config.gem 'will_paginate', :version => '2.3.14'

3. Restart the server, and got the result:
undefined method `paginate' for #<Class:0x66a2718>
>
> --
> Posted viahttp://www.ruby-forum.com/.

Jeff Chen

unread,
Aug 30, 2010, 10:49:03 PM8/30/10
to Ruby on Rails: Talk


On 8月30日, 下午8時19分, Colin Law <clan...@googlemail.com> wrote:
The item.rb of model is :
class Item < ActiveRecord::Base
end

Do I need to add the codes into the item.rb?
>
> I am running out of ideas however.

I am so happy to get your support, because it confuse me for several
months, and I believe you can help me because you own 6 stars in this
Talk.
>
> Colin

Colin Law

unread,
Aug 31, 2010, 3:57:44 AM8/31/10
to rubyonra...@googlegroups.com

No, what you have looks ok.

Only one more suggestion I think, I seem to remember some-one having a
similar problem and it went away when they used Mongrel instead of
Webrick, though I do not understand why. I can only suggest you try
that, so start the server with
ruby script/server --mongrel
and see what happens. I always use mongrel as for me it loads much faster.

Colin

Jeff Chen

unread,
Aug 31, 2010, 5:33:07 AM8/31/10
to Ruby on Rails: Talk


On 8月31日, 下午3時57分, Colin Law <clan...@googlemail.com> wrote:
I did run: ruby script/server --mongrel , and got the result is
"server : invalid option --mongrel".
Where to get the mongrel, and how to fix it up when I run above
command again?

Colin Law

unread,
Aug 31, 2010, 5:44:23 AM8/31/10
to rubyonra...@googlegroups.com
On 31 August 2010 10:33, Jeff Chen <jeffch...@gmail.com> wrote:
>
>
> On 8月31日, 下午3時57分, Colin Law <clan...@googlemail.com> wrote:
>>...

>> Only one more suggestion I think, I seem to remember some-one having a
>> similar problem and it went away when they used Mongrel instead of
>> Webrick, though I do not understand why.  I can only suggest you try
>> that, so start the server with
>> ruby script/server --mongrel
>
> I did run: ruby script/server --mongrel , and got the result is
> "server : invalid option --mongrel".
> Where to get the mongrel, and how to fix it up when I run above
> command again?

I don't know, it just worked for me, in fact it defaults to mongrel on
my Ubuntu install. Have you tried googling for rails install mongrel?

Colin

Samuel Flores

unread,
Aug 31, 2010, 9:25:04 AM8/31/10
to Ruby on Rails: Talk
you just need to have mongrel gem installed on your system and `ruby
script/server` will run with it.


On Aug 31, 6:44 am, Colin Law <clan...@googlemail.com> wrote:

Jeff Chen

unread,
Aug 31, 2010, 11:19:40 PM8/31/10
to Ruby on Rails: Talk


On 8月31日, 下午9時25分, Samuel Flores <samflo...@gmail.com> wrote:
> you just need to have mongrel gem installed on your system and `ruby
> script/server` will run with it.
>
I input : gem install mongrel --include-dependencies and gem install
mongrel_service --include-dependencies

and run the script/server got the result:
c:/ruby/lib/gems/actionpack-2.3.8/lib/../_trace.erb:23: warning:
parenthesize argument(s) for future version.

then I run the localhost:3000/manage then got the error msg:
undefined method `paginate' for #<Class:0x60f629c>

I checked the system status of mongrel, which is empty. which means
the system is not active when I run above commands.

Jeff Chen

unread,
Sep 7, 2010, 5:53:44 AM9/7/10
to Ruby on Rails: Talk
Someone can give me the answer --- how to active the mongrel
successful, and how to fix the invalid option? Thanks.

Colin Law

unread,
Sep 7, 2010, 4:14:20 PM9/7/10
to rubyonra...@googlegroups.com
On 1 September 2010 04:19, Jeff Chen <jeffch...@gmail.com> wrote:
>
>
> On 8月31日, 下午9時25分, Samuel Flores <samflo...@gmail.com> wrote:
>> you just need to have mongrel gem installed on your system and `ruby
>> script/server` will run with it.
>>
> I input : gem install mongrel --include-dependencies and gem install
> mongrel_service --include-dependencies
>
> and run the script/server got the result:
> c:/ruby/lib/gems/actionpack-2.3.8/lib/../_trace.erb:23: warning:
> parenthesize argument(s) for future version.

Can you post the complete output seen in the terminal when you start
mongrel and enter localhost:3000/manage in the browser.

>
> then I run the localhost:3000/manage then got the error msg:
> undefined method `paginate' for #<Class:0x60f629c>
>
> I checked the system status of mongrel, which is empty. which means
> the system is not active when I run above commands.

What do you mean by the system status of mongrel? If mongrel is not
running I do not see how you get any output at all in the browser.

Also please post complete output of
gem list --local

Colin

Jeff Chen

unread,
Sep 7, 2010, 10:15:19 PM9/7/10
to Ruby on Rails: Talk


On 9月8日, 上午4時14分, Colin Law <clan...@googlemail.com> wrote:
The status is space, not running at all. How to activate it?
>
> Also please post complete output of
> gem list --local

Here is the complete output of gem list --local:
actionmailer (2.3.8, 2.3.5, 1.2.1)
actionpack (2.3.8, 2.3.5, 1.12.1)
actionwebservice (1.1.2)
activerecord (2.3.8, 2.3.5, 1.14.2)
activeresource (2.3.8, 2.3.5)
activesupport (2.3.8, 2.3.5, 1.3.1)
cgi_multipart_eof_fix (2.5.0)
fxri (0.3.6)
fxruby (1.6.12 mswin32)
gem_plugin (0.2.3)
hpricot (0.6 mswin32)
log4r (1.0.5)
mongrel (1.1.5 x86-mswin32-60)
mongrel_cluster (1.0.5)
mongrel_service (0.3.4 i386-mswin32)
mysql (2.8.1 x86-mswin32)
paginate (0.1.1)
rack (1.1.0, 1.0.1)
rails (2.3.8, 2.3.5, 1.1.2)
rake (0.8.7, 0.7.3)
rubygems-update (1.3.7, 1.3.6)
sources (0.0.1)
sqlite3-ruby (1.3.0 x86-mswin32-60)
will_paginate (2.3.14)
win32-api (1.0.4 mswin32)
win32-clipboard (0.4.3)
win32-dir (0.3.2)
win32-eventlog (0.4.6)
win32-file (0.5.4)
win32-file-stat (1.2.7)
win32-process (0.5.3)
win32-sapi (0.1.4)
win32-service (0.5.2 mswin32)
win32-sound (0.4.1)
windows-api (0.2.0)
windows-pr (0.7.2)

>
> Colin

Frederick Cheung

unread,
Sep 8, 2010, 3:14:32 AM9/8/10
to Ruby on Rails: Talk


On Sep 1, 4:19 am, Jeff Chen <jeffchen1...@gmail.com> wrote:
> and run the script/server got the result:
> c:/ruby/lib/gems/actionpack-2.3.8/lib/../_trace.erb:23: warning:
> parenthesize argument(s) for future version.
>
> then I run the localhost:3000/manage then got the error msg:
> undefined method `paginate' for #<Class:0x60f629c>

Are you definitely only calling paginate on ActiveRecord classes? Are
you able to reproduce the problem in a fresh, empty, rails app?

Fred

Colin Law

unread,
Sep 8, 2010, 4:31:37 AM9/8/10
to rubyonra...@googlegroups.com
On 8 September 2010 03:15, Jeff Chen <jeffch...@gmail.com> wrote:
>
>
> On 9月8日, 上午4時14分, Colin Law <clan...@googlemail.com> wrote:
>> On 1 September 2010 04:19, Jeff Chen <jeffchen1...@gmail.com> wrote:
>>
>>
>>
>> > On 8月31日, 下午9時25分, Samuel Flores <samflo...@gmail.com> wrote:
>> >> you just need to have mongrel gem installed on your system and `ruby
>> >> script/server` will run with it.
>>
>> > I input : gem install mongrel --include-dependencies and gem install
>> > mongrel_service --include-dependencies
>>
>> > and run the script/server got the result:
>> > c:/ruby/lib/gems/actionpack-2.3.8/lib/../_trace.erb:23: warning:
>> > parenthesize argument(s) for future version.
>>
>> Can you post the complete output seen in the terminal when you start
>> mongrel and enter localhost:3000/manage in the browser.

You have not provided this information.

Could the fact that you have paginate and will_paginate installed be
an issue? It might be worth removing this one.

Colin

Jeff Chen

unread,
Sep 8, 2010, 9:44:28 PM9/8/10
to Ruby on Rails: Talk


On 9月8日, 下午4時31分, Colin Law <clan...@googlemail.com> wrote:
I did remove all the file and directory of paginate, and got the
result when run the http://localhost:3000/manage after running the
ruby script/server:

Processing ManageController#index (for 127.0.0.1 at 2010-09-09
09:40:06) [GET]
[4;36;1mSQL (2.0ms) [0m [0;1mSHOW TABLES [0m
[4;35;1mItem Columns (4.0ms) [0m [0mSHOW FIELDS FROM `items` [0m

NoMethodError (undefined method `paginate' for #<Class:0x607f0ac>):
app/controllers/manage_controller.rb:25:in `list'
app/controllers/manage_controller.rb:4:in `index'

Rendered rescues/_trace (117.0ms)
Rendered rescues/_request_and_response (1.0ms)
Rendering rescues/layout (internal_server_error)

Colin Law

unread,
Sep 9, 2010, 3:02:16 AM9/9/10
to rubyonra...@googlegroups.com
On 9 September 2010 02:44, Jeff Chen <jeffch...@gmail.com> wrote:
>
>
> On 9月8日, 下午4時31分, Colin Law <clan...@googlemail.com> wrote:
>> On 8 September 2010 03:15, Jeff Chen <jeffchen1...@gmail.com> wrote:
>>
>>
>>
>>
>>
>> > On 9月8日, 上午4時14分, Colin Law <clan...@googlemail.com> wrote:
>> >> On 1 September 2010 04:19, Jeff Chen <jeffchen1...@gmail.com> wrote:
>>
>> >> > On 8月31日, 下午9時25分, Samuel Flores <samflo...@gmail.com> wrote:
>> >> >> you just need to have mongrel gem installed on your system and `ruby
>> >> >> script/server` will run with it.
>>
>> >> > I input : gem install mongrel --include-dependencies and gem install
>> >> > mongrel_service --include-dependencies
>>
>> >> > and run the script/server got the result:
>> >> > c:/ruby/lib/gems/actionpack-2.3.8/lib/../_trace.erb:23: warning:
>> >> > parenthesize argument(s) for future version.
>>
>> >> Can you post the complete output seen in the terminal when you start
>> >> mongrel and enter localhost:3000/manage in the browser.
>>
>> You have not provided this information.

So what happened to the problem running mongrel?

Colin

Reply all
Reply to author
Forward
0 new messages