루비, Paginator.new

armyinsa의 이미지


데이터를 읽어들어서.

10폐이지만 표기 하려고 하는데... 잘 안되네요.~!@@

dis_count = 10
@nice = Inquiry.search(nil, nil, condition)
@pages = Paginator.new self, @nice.size, dis_count, params[:page]
@nices = nice.search(@pages.current.offset, disp_count, condition)

여기에서
@pages = Paginator.new self, @nice.size, dis_count, params[:page]
에서 에러가 납니다.

wrong number of arguments (4 for 2)

식으로요...

아큐멘터가 맞지않는건인지요?

이것때문 시간 다 잡아먹네요..~~!!! 에궁...

무엇이 문제인지요?

unsouled의 이미지

사용하고 있는 Rails 버젼은 어떻게 되나요?
Paginator 는 Rails 2.0.x 부터 ActionController 에서 빠졌습니다.

Paginator 라는 클래스가 정의는 되어 있는 걸 보면, 아마 Pagination 관련 플러그인이나 gem 이 설치가 되어 있는 것 같은데
해당 플러그인이나 gem 의 문서를 찾아 해결하세요. (적어도 will_paginate 는 아니군요.)

에러의 내용은 Paginator.new 의 인자는 2개 필요하지만 4개가 넘어왔다라는 뜻입니다.

armyinsa의 이미지

버전
Rails 2.3.5

Pagination 관련 플러그인이나 gem 이 설치가 되었습니다.
will_paginate 는 아닙니다.

self 컨트롤러
@nice.size 전체수
@dis_count 1페이지 건수
@params[:page] page로 전해진 파라메타

@pages = Paginator.new self, @nice.size, dis_count, params[:page]에서

params[:page]가 nil 인것이 걸리는데.. 상관없나보네요...

아...미치것다..

하루가 걸리네요~~!!ㅡㅜ;

lateau의 이미지

관련 gem을 써본 적이 없어 잘 모르겠습니다만,

>> wrong number of arguments (4 for 2)

이 에러는 Paginator.new 가 요구하는 인수의 개수가 맞지 않다는 의미네요. 2개만 필요한데 4개가 들어가니, new라는 클래스 메소드가 initialize 메소드로 class instance를 초기화할 수 없기에 발생하는 에러입니다.

>> @pages = Paginator.new self, @nice.size, dis_count, params[:page]에서
>> params[:page]가 nil 인것이 걸리는데.. 상관없나보네요...

params[:page]가 nil이라면 wrong number of arguments가 아닌 다른 부분에서 에러가 발생(아마도 name이나 NilClassError)할 겁니다.

$ ri Paginator

로 간단히 Paginator의 메뉴얼을 한 번 읽어 보시기를 추천합니다.

만약 Paginator가 plugin으로 들어와있다면 ri로는 검색이 안될테니 에러메시지에 표시된 파일과 행수를 따라 올라가서 Paginator#initialize 부분을 살펴보시면 에러가 나는 이유를 알 수 있을 것 같습니다.

--
I think to myself...what a emerging world.

unsouled의 이미지

Paginator.new 의 모양으로 살펴보니, 아마 플러그인은 http://paginator.rubyforge.org/ 이 플러그인인 것 같군요.

그리고 사용하려고 하는 코드는 확실히 Rails 1.2.x 대에 있던 ActionController 에 있던 Paginator API 입니다.

문서를 보니...

Paginator.new(@nice.size, dis_count) { |offset, per_page|
  Inquiry.all(:limit => per_page, :offset => offset)
}

이렇게 써야 하는 것 아닌가요?

neocoin의 이미지

unsouled 님의 말씀이 정확한 것 같습니다.

http://paginator.rubyforge.org/ 사용하시는데 도움말은 관계없는

http://apidock.com/rails/ActionController/Pagination/Paginator/new/class 이걸 보고 계신거 같네요.
문서 보시다시피 1.2.6 부터 사라졌습니다.

관련 new 생성자 도움말은 http://paginator.rubyforge.org/classes/Paginator.html#M000001 같습니다.

ps.
will_paginate 쓰고 있는데, 추천합니다. http://wiki.github.com/mislav/will_paginate/
plugin 방식은 rake gems로 잘 관리가 안되더군요.

armyinsa의 이미지


알려 주셔서 감사합니다...

관련자료들을 보고 해결하겠습니다... -- 고맙습니다...-꾸벅..

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.