作者godfat (godfat 真常)
看板Ruby
标题Re: [RoR ] 新手问题 -- Paginate 无法使用?
时间Sat Dec 13 22:50:31 2008
※ 引述《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://webptt.com/cn.aspx?n=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
1F:推 cuteman0725:刚刚看了一下 这个scaffold好像还不错 先抓来玩一下XD 12/14 00:38
2F:→ cuteman0725:看来还是得找一本讲比较新的 不然挫折感蛮重的 :p 12/14 00:39