Pagi something :(

Errors, errors and more errors :frowning:

路路路

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

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>

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

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

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

http://groups.google.com/group/rubyonrails-talk

Ben

路路路

On Sat, Apr 17, 2010 at 2:28 PM, Tiger Big one <woo_@hotmail.co.uk> wrote:

Errors, errors and more errors :frowning: