undefined method `paginate'

52 views
Skip to first unread message

Amir Z.

unread,
May 22, 2012, 9:37:04 AM5/22/12
to rubyonra...@googlegroups.com
I am working with Railsspace social networking book. I stuck in the
problem when i am doing paginate for the search result. It gives the
following error.

NoMethodError in CommunityController#index

undefined method `paginate' for #<CommunityController:0x57436f0>

My Controller Index page coding is below

def index
@title = "Community"
@letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
if params[:id]
@initial = params[:id]
@pages, specs = paginate(:specs,
:conditions => ["last_name LIKE ?", @initial+"%"],
:order => "last_name, first_name")
@users = specs.collect { |spec| spec.user }
end
end

Please help me out.

Any help is appreciable.

Thanks
Amir

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

Juan Pablo Avello

unread,
May 22, 2012, 9:55:16 AM5/22/12
to rubyonra...@googlegroups.com
You dont have a "def paginate " method defined in your controller.
Anyway you'll probably want to use a pagination gem such as Kaminari, which includes all you need for that purpose.

Amir Z.

unread,
May 23, 2012, 2:31:51 AM5/23/12
to rubyonra...@googlegroups.com
> You dont have a "def paginate " method defined in your controller.
> Anyway you'll probably want to use a pagination gem such as Kaminari,
> which
> includes all you need for that purpose.

Hi Juan,

Thanks for the help message. Juan I am newbie on ROR could you please
help me how to install kaminari.

Is it right command to run "gem install kaminari" as I am working on
windows.

Thanks in advance

Juan Pablo Avello

unread,
May 23, 2012, 7:09:03 AM5/23/12
to rubyonra...@googlegroups.com
It's right, but your best approach is to add 'gem kaminari' to your Gemfile and to use rvm.

I don't have much experience on rails + windows issues, but I know they can be a real pain, so I'd also suggest that you use linux instead for rails development, in a virtual machine if for some reason you can't install linux in your computer. 

Matt Jones

unread,
May 24, 2012, 4:23:46 PM5/24/12
to rubyonra...@googlegroups.com


On Tuesday, 22 May 2012 09:37:04 UTC-4, Ruby-Forum.com User wrote:
I am working with Railsspace social networking book. I stuck in the
problem when i am doing paginate for the search result. It gives the
following error.


Don't use that book - it's severely outdated and will cause you a lot of problems. See here for details:


--Matt Jones 
Reply all
Reply to author
Forward
0 new messages