# Pagi something :(

**URL:** <https://www.ruby-forum.com/t/pagi-something/187133>\
**Category:** Ruby\
**Created:** [April 17, 2010, 11:27pm UTC](https://www.ruby-forum.com/t/pagi-something/187133 "2010-04-17T23:27:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guru\_101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/77aa72/32.png) [@guru\_101](https://www.ruby-forum.com/u/guru_101)\
**Post date:** [April 17, 2010, 11:27pm UTC](https://www.ruby-forum.com/t/pagi-something/187133/1 "2010-04-17T23:27:33Z")

</div>

Errors, errors and more errors ☹

########################

NameError in UserController#index

uninitialized constant ApplicationController::Paginator

########################

RAILS\_ROOT:  
C:/Users/[UsEr]/Documents/Downloads/InstantRails-2.0-win/rails\_apps/jagmits\_books

C:/Users/[UsEr]/Documents/Downloads/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active\_support/dependencies.rb:478:in  
`const_missing' app/controllers/application.rb:22:in`paginate’  
app/controllers/application.rb:30:in `make_profile_vars' app/controllers/user_controller.rb:9:in`index’

################################################  
this is additonal information  
################################################

app/controllers/application.rb  
########################

# Filters added to this controller apply to all controllers in the

application.

# Likewise, all the methods added will be available for all controllers.

class ApplicationController \< ActionController::Base  
helper :all # include all helpers, all the time

# See ActionController::RequestForgeryProtection for details

# Uncomment the :secret if you’re not using the cookie session store

protect\_from\_forgery # :secret =\> ‘f63938e58dda32a445f30fa95a2bea9f’

# Paginate item list if present, else call default paginate method.

def paginate(arg, options = {})  
if arg.instance\_of?(Symbol) or arg.instance\_of?(String)  
# Use default paginate function.  
collection\_id = arg # arg is, e.g., :specs or “specs”  
super(collection\_id, options)  
else  
# Paginate by hand.  
items = arg # arg is a list of items, e.g., users  
items\_per\_page = options[:per\_page] || 10  
page = (params[:page] || 1).to\_i  
result\_pages = Paginator.new(self, items.length, items\_per\_page,  
page)  
offset = (page - 1) \* items\_per\_page  
[result\_pages, items[offset…(offset + items\_per\_page - 1)]]  
end  
end

def make\_profile\_vars  
@blog = @user.blog ||= Blog.new  
@pages, @posts = paginate(@blog.posts, :per\_page =\> 3)  
end

end  
########################

app/controllers/user\_controller.rb  
########################

def index  
@title = “Users - Books”  
@user = User.find\_by\_id(session[:user\_id])  
@blog = @user.blog ||= Blog.new  
make\_profile\_vars  
end

########################

app/view/user/index.rhtml  
########################

\<% if paginated? %\> \<% first = @pages.current\_page.first\_item %\> \<% last = @pages.current\_page.last\_item %\> \<% if first == last %\> Post \<%= last %\> of \<% else %\> Posts \<%= first %\>–\<%= last %\> of \<% end %\> \<% end %\> \<%= pluralize(@blog.posts.count, "blog post") %\>

\<%= render :partial =\> "posts/post", :collection =\> @posts %\> \<%= "Pages: #{pagination\_links(@pages)}" if paginated? %\>

########################

########################

---

<div class="post-metadata">

**Author:** ![guru\_101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/77aa72/32.png) [@guru\_101](https://www.ruby-forum.com/u/guru_101)\
**Post date:** [April 18, 2010, 12:53am UTC](https://www.ruby-forum.com/t/pagi-something/187133/2 "2010-04-18T00:53:55Z")

</div>

On Sat, Apr 17, 2010 at 2:28 PM, Tiger Big one [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Errors, errors and more errors ☹

Please go ask the Rails list. They are better equipped to help you than  
we are.

[http://groups.google.com/group/rubyonrails-talk](http://groups.google.com/group/rubyonrails-talk)

Ben
