Pagi something :(

T

Tiger Big one

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
########################


<div id="blog">
<p>
<% if paginated? %>
<% first = @pages.current_page.first_item %>
<% last = @pages.current_page.last_item %>
<% if first == last %>
Post <%= last %> of
<% else %>
Posts <%= first %>&ndash;<%= last %> of
<% end %>
<% end %>
<%= pluralize(@blog.posts.count, "blog post") %>
</p>
<%= render :partial => "posts/post", :collection => @posts %>
<%= "Pages: #{pagination_links(@pages)}" if paginated? %>
</div>

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



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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,821
Messages
2,569,748
Members
45,726
Latest member
RaleighAll

Latest Threads

Top