From: Tiger Big one on 17 Apr 2010 17:28 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 %>–<%= 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/.
From: Ben Bleything on 17 Apr 2010 18:53 On Sat, Apr 17, 2010 at 2:28 PM, Tiger Big one <woo_(a)hotmail.co.uk> 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 Ben
|
Pages: 1 Prev: Undifined local variable or method error Next: unsubscribe |