2010-04-15 8 views
2

will_paginate에 대해 단지 installed the gem이고 성공적으로 설치되었다고합니다. 나는 all the instructions을 따라 플러그인 목록에 올랐고 '정의되지 않은 메쏘드`paginate'for '오류가 나타납니다. Google 검색의 방법으로 많이 찾을 수 없으며 직접 수정할 수는 없습니다 (분명히).will_paginate 정의되지 않은 메소드 오류 - Ruby on Rails

가 PostsController

def index 
    @tag_counts = Tag.count(:group => :tag_name, :order => 'updated_at DESC', :limit => 10) 
    @posts = Post.paginate :page => params[:page], :per_page => 50 

    respond_to do |format| 
     format.html # index.html.erb 
     format.xml { render :xml => @posts } 
     format.json { render :json => @posts } 
     format.atom 
    end 
    end 

/model/post.rb

class Post < ActiveRecord::Base 
    validates_presence_of :body, :title 
    has_many :comments, :dependent => :destroy 
    has_many :tags, :dependent => :destroy 

    cattr_reader :per_page 
    @@per_page = 10 

end 

/posts/views/index.html.erb

<%= will_paginate @posts %> 

UPDATE I : 여기에 코드입니다 will_paginate가 올바르게 올바르게 설치되었는지 확인하기 위해 스크립트/콘솔을 사용했습니다. 나는 /config/environments.rb 파일에

config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org' 

을 추가하고 서버를 다시 시작해야했습니다. 훌륭하게 작동합니다.

답변

2

will_paginate가 올바르게 설치되었는지 확인하기 위해 스크립트/콘솔을 사용했습니다. 추가 할 내용 :

config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter. 

위대한 작품입니다. 간단한 수정.

2

내가 실수로 배치했기 때문에 will_paginate gem (Rails 3 사용)에서 정의되지 않은 메소드 오류가 발생했습니다. . .

gem 'will_paginate' 

. . . 명령을 Gemfile의 잘못된 위치에 추가하십시오.

group :test do 
. 
. 
. 
end 
과 같이 파티션 된 환경에서 번들 내에 중첩되지 않은 모든 런타임 환경에서 사용할 수있는 위치에 배치했는지 확인하십시오.
관련 문제