Re: [RoR ] 新手問題 -- Paginate 無法使用?
※ 引述《cuteman0725 (Q麵)》之銘言:
: 首先先感謝版大的回覆 <(_ _)>
: 後來試了您的方法,學到了不少東西﹙順便把 will_paginate 改成 2.3.6 XD﹚
: 只是結果就和一開始相同,出現「undefined method `paginate' 」
: 然後又去 Google 了一下~~
: 根據網路上的討論,動態scaffold + will_paginate 看起來似乎合不起來~
: 沒辦法在 Controller 下只靠一行 "scaffold model名" 就能直接運行。
: ﹙也許是我的觀念不對,但之前我測的範例並沒有產生 view﹚
: 後來找到的範例似都需要用靜態scaffold來產生文件後,再套用 will_paginate
: ﹙似乎是一定要有 index.rhtml,如以下的例子﹚
: http://hdj-berkeley.blogspot.com/search/label/ruby
: 總之我想先跳過動態scaffold + paginate的組合。先來試試靜態的scaffold~ :p
: 等到以後有 paginate 能順利的跑動態 scaffold 再回來試試~
如果你都是看書然後上網查資料的話,我是建議你換書吧... XD
看到 scaffold 這個字眼,感覺是好久以前的事了... [遠目]
所以我一直以為那個 undefined method `paginate' 是你打的。
這樣看來應該是你灌的 plugin 用上了那個東西。
要用那個 scaffold 可能就要用 classic_pagination,
而要用 classic_pagination 也不能用太新的 rails... (根據你的經驗)
基本上如果你需要 scaffold 的功能,或許可以試試 active_scaffold:
http://github.com/activescaffold/active_scaffold
根據他的 README, 只有 master 才支援 2.2.2...
所以如果你要用最新版的 rails, 勢必得用開發版囉。
不過如果你只要快速 workaround, 可以試試看在 application.rb 裡定義:
def paginate *args
args.shift.paginate(*args)
end
private :paginate
之類的東西看看。我沒看 scaffold 怎麼寫的,反正就是看他錯在哪,
改成正確的作法,或是他欠什麼 method 你就幫他補上去...
基本上這對新手來說應該不會是一件簡單的事,如果你只是要功能,
還是先看看 active_scaffold 再說。畢竟那東西有人維護 XD
==
寫 rails 的東西,超過一個月就是過期,遑論 scaffold 可能超過一年了 XD
--
#!/usr/bin/env ruby [露比] /Programming (Kn|N)ight/ 看板《Ruby》
# if a dog nailed extra legs that http://www.ptt.cc/bbs/Ruby/index.html
# walks like an octopus, and Welcome ~Ruby@ptt~
# talks like an octopus, then ◢█◣ http://www.ruby-lang.org/
# we are happy to treat it as █ http://www.ruby-doc.org/
# if it were an octopus. ◥ ◤ http://www.rubyforge.org/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.28.18
推
12/14 00:38, , 1F
12/14 00:38, 1F
→
12/14 00:39, , 2F
12/14 00:39, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):