- 浏览: 326965 次
- 来自: 上海交通大学软件学院
文章分类
最新评论
-
whatable:
楼主写得很好!!
小试org.eclipse.jface.dialogs.TitleAreaDialog -
yeshaoting:
顶~~顶~~顶~~
另一只眼看Eclipse,所谓的开源 -
wenhai_zhang:
好,不错。发贴留地址
小试org.eclipse.jface.dialogs.TitleAreaDialog -
ss1:
具体点,我还是不会啊
在Liferay Portal中使用DWR -
rubynroll:
robbin 写道每次当我想操起ruby写rake file的 ...
我的第一关rake文件
大家可以试验一下,在我的开发环境中会出现这个问题,不知道是不是只有我有问题。做法如下:
[list]随便建立一个Rails工程;
随便生成一个scaffold_resource,比如map.resources :articles;
在routes.rb中加入如下代码,添加自己的routes mapping:
在ArticlesController中声明方法paginate,然后随便以任何方式从view中调用这个url。
[/list]
我这里产生的结果是unknow action。这说明routes mapping已经起作用了,但是找不到paginate方法。
我知道我想要的mapping可以通过rails自带的方式实现,不需要自己写mapping。但是由于某些原因,我无法使用自带的实现方式。而且按道理我自己mapping也不应该有问题。请各位看看是怎么回事儿。
另外,顺便讨论一下RESTful的paginate应该如何实现。OK,我知道有人会说不要为了REST而REST,要用在合适的地方。这我同意,就是想讨论一下。如果结论就是REST不适合用在paginate上,那就不用呗。
我在自己的代码中使用paginate,
但是出现了如下问题:
ArgumentError in ArticlesController#index
wrong number of arguments (2 for 0)
RAILS_ROOT: /Users/benben/Documents/workspace/playground/config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `paginate'
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `index'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16:in `load'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `synchronize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `paginate'
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `index'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `synchronize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16:in `load'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16
Request
Parameters: None
Show session dump
---
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
那你能解释一下为什么我自己加的mapping会找不到action吗?谢谢。
[list]
map.articles_paginate "articles;paginate", :controller => 'articles', :action => 'paginate', :conditions => { :method => :get }
我这里产生的结果是unknow action。这说明routes mapping已经起作用了,但是找不到paginate方法。
我知道我想要的mapping可以通过rails自带的方式实现,不需要自己写mapping。但是由于某些原因,我无法使用自带的实现方式。而且按道理我自己mapping也不应该有问题。请各位看看是怎么回事儿。
另外,顺便讨论一下RESTful的paginate应该如何实现。OK,我知道有人会说不要为了REST而REST,要用在合适的地方。这我同意,就是想讨论一下。如果结论就是REST不适合用在paginate上,那就不用呗。
评论
5 楼
AllenYoung
2007-07-18
找到原因了,paginate是ActionController::Pagination中的一个方法的名字,在ActionController中是hidden action。换个名字就好了,哎。
4 楼
AllenYoung
2007-07-18
现在更奇怪,连这样的标准写法都不行了...
map.resources :articles, :collection => { :paginate => :get }
3 楼
AllenYoung
2007-07-18
hideto 写道
该怎样实现还怎样实现
比如TopicsController中:
参考Beast的源码即可
比如TopicsController中:
@post_pages, @posts = paginate(:posts, :per_page => 5, : order => 'posts.created_at', :conditions => ['posts.topic_id = ?', params[:id]])
参考Beast的源码即可
我在自己的代码中使用paginate,
def index # @articles = Article.find(:all) @article_pages, @articles = paginate :articles, :per_page => 1 respond_to do |format| format.html # index.rhtml format.xml { render :xml => @articles.to_xml } end end
但是出现了如下问题:
ArgumentError in ArticlesController#index
wrong number of arguments (2 for 0)
RAILS_ROOT: /Users/benben/Documents/workspace/playground/config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `paginate'
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `index'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16:in `load'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `synchronize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `paginate'
#{RAILS_ROOT}/app/controllers/articles_controller.rb:6:in `index'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in `call_filter'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in `perform_action'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `send'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in `process_without_filters'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `synchronize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `each'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16:in `load'
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/powerpc/bin/mongrel_rails:16
Request
Parameters: None
Show session dump
---
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}
2 楼
AllenYoung
2007-07-18
hideto 写道
该怎样实现还怎样实现,参考Beast的源码即可。
那你能解释一下为什么我自己加的mapping会找不到action吗?谢谢。
1 楼
hideto
2007-07-18
该怎样实现还怎样实现
比如TopicsController中:
show.rhtml中:
参考Beast的源码即可
比如TopicsController中:
@post_pages, @posts = paginate(:posts, :per_page => 5, : order => 'posts.created_at', :conditions => ['posts.topic_id = ?', params[:id]])
show.rhtml中:
<% if @post_pages and @post_pages.current.next %> <%= link_to "Next page", { :page => @post_pages.current.next } %> <% end %> <% if @post_pages and @post_pages.current.previous %> <%= link_to "Previous page", { :page => @post_pages.current.previous } %> <% end %> <% if @post_pages.page_count > 1 %> <%= _('Pages:') %> <%= pagination_links @post_pages, :window_size => 10 %><% end %>
参考Beast的源码即可
发表评论
-
批量下载railscasts上视频的ruby脚本
2008-07-14 12:00 2744Railscasts 上面的视频已经出到117集了,很早就想把 ... -
在Leopard上使用NetBeans Ruby IDE
2008-01-17 10:57 1969本来像NetBeans这样到东东,应该是装上就可以用到。但是在 ... -
在Leopard上手动安装RMagick
2008-01-17 10:44 2032这几天刚刚给自己的小白安装了Leopard,开始迫不及待的把开 ... -
使用ruby生成zip文件
2007-10-23 17:28 6115首先安装rubyzip: gem install rubyz ... -
在habtm上使用polymorphic关联
2007-10-05 15:19 2676我们知道,在rails中,ha ... -
尝试在rails中调用MySql的stored procedure,不过最终放弃了。
2007-10-03 17:00 3671手头一个项目有这样一个需求,数据库中有一张学生表student ... -
我的第一关rake文件
2007-09-23 17:10 4126早就想找个机会写写rake文件,但是接触到的项目都不怎么需要, ... -
ferret啊,为你欢喜为你忧。
2007-08-09 18:05 2503非常非常奇怪的问题。一开始在mac下面用standard ra ... -
在Mac上安装RMagick?别以为有了Locomotive就万事大吉啦~
2007-08-02 09:30 2691我或多或少算是一个Mac ... -
在controller里面怎么escape html内容?
2007-07-24 10:24 3582在view里面可以用h来escape html内容。那在con ... -
ActiveRecord中表关联的一个问题,belongs_to和has_many不是一一对应的情况。
2007-07-19 18:15 4027一个挺有意思的问题,想了半天没有解决办法。 情景是这样的:系 ... -
[讨论]部署Rails的最佳方案是什么?
2007-07-06 13:46 13571从来没真正部署过一个production级别的rails应用, ... -
Rails中使用REST,登录相关的问题,如何获得当前正在处理的url?
2007-07-03 16:39 3918如果整个routes是使用传统的mvc方式实现的话,我们可以简 ... -
Eclipse 3.3携Europa正式发布了
2007-07-01 12:57 33766刚刚逛了一圈论坛,竟 ... -
在apple上使用ruby的郁闷事儿
2007-06-23 19:49 2034安装了那个Locomotive,还有iTerm,还有Textm ... -
在ubuntu下安装ruby需要注意的事情
2007-06-23 19:41 4965这里说的是通过apt-get安装ruby,自己编译的情况就免了 ... -
基于model动态地ComboBox为生成options
2007-06-17 16:17 2312在使用RoR创建form时,很多时候需要基于model之间的关 ... -
Meta-Programming in Ruby: 动态生成class,并添加attribute和method。
2006-12-17 16:10 4917Ruby的动态语言特性和强大的meta-programming ...
相关推荐
ActiveResource 是 Rails 提供的一个库,用于实现 RESTful 客户端。它可以方便地与 RESTful 服务器交互。 #### 1.17 最终总结 通过上述讨论,可以看出 RESTful 开发不仅是一种技术实践,也是一种设计理念。通过...
RESTful设计的一个关键特性是使用动词和名词来构建URL。例如,`/users`表示用户资源,而`/users/1`表示ID为1的具体用户。对于CRUD(Create, Read, Update, Delete)操作,Rails提供了如下的默认映射: - GET /users...
Rails的RESTful控制器通常遵循这些约定,例如,对于一个用户资源,其URL可能为`/users/1`,通过GET请求可以获取该用户的详情,而PUT或PATCH请求则可以更新用户信息。 ### RESTful路由与视图 在Rails中,RESTful...
Rails ::路线 您的Rails应用程序上的路线太多?...将这个gem添加到您的项目后,您可以在config/routes创建多个路由文件。 只要确保您用 # config/routes/v1.rb Rails . application . routes . draw do
ActiveResource 是 Rails 提供的一个库,用于构建 RESTful 客户端,使得与远程服务的交互变得更加简单。 **ActiveResource 示例**: ```ruby class Task self.site = "http://example.com" end ``` 这段代码...
- 测试安装: 创建一个简单的Rails应用来验证是否成功安装。 #### 五、练习作业0-Hello World - **目标**: - 学习如何创建第一个Rails应用程序。 - **过程**: - 创建新项目。 - 设置数据库配置。 - 创建控制器...
Rails是一个流行的开源Web应用程序框架,基于Ruby编程语言。在Rails应用中实现用户登录和验证是构建任何Web服务的基础。本文将深入探讨Rails中的http_authentication和restful-authentication插件,这两种方法都常...
根据提供的文件信息,我们可以推断出这是一本关于如何使用Ruby on Rails框架来构建RESTful应用程序和服务的专业书籍。书名为《RESTful Rails Development》,作者为Silvia Puglisi,出版时间为2015年10月。接下来,...
`will_paginate`是Rails框架中非常流行的一个分页插件,版本2.2.2是它的一个历史版本。在本文中,我们将深入探讨`will_paginate`的使用方法、功能特性以及它如何与Rails集成,帮助提升Web应用的性能和用户体验。 一...
这个“Rails项目源代码”是一个使用Rails构建的图片分享网站的完整源代码,它揭示了如何利用Rails的强大功能来创建一个允许用户上传、分享和浏览图片的应用。 1. **Rails框架基础**: Rails的核心理念是DRY(Don't...
Rails(Ruby on Rails)是一个采用Ruby语言编写的开源Web应用框架,它遵循模型-视图-控制器(MVC)的架构模式,设计用来快速开发数据库驱动的动态网页。随着Rails版本的更新迭代,此书聚焦于一个特定的版本,帮助...
Routes is a Python re-implementation of the Rails routes system for mapping URLs to application actions, and conversely to generate URLs. Routes makes it easy to create pretty and concise URLs that ...
在本篇内容中,我们将深入探讨如何利用Ruby on Rails(简称Rails)这一强大的Web应用程序框架来构建可伸缩且易于维护的RESTful API。Rails以其简洁优雅的语法、高效的开发速度以及良好的社区支持而闻名,这使得它...
Rails指南中文版是针对Ruby on Rails框架的一份详尽教程,旨在帮助开发者深入理解并熟练掌握这个强大的Web应用开发工具。Ruby on Rails(简称Rails)是一个基于Ruby语言的开源Web应用框架,它遵循MVC(Model-View-...
RESTful-Rails-开发 RESTful Rails 开发库。 你好 Rails 类别图 API - WIKICAT 本地图片 带有地理标记的维基百科文章 - WIKIPINS 城市步道API 余烬漫步
Ruby on Rails,通常简称为Rails,是一个基于Ruby语言的开源Web应用程序框架,它遵循MVC(模型-视图-控制器)架构模式,以简洁、高效的代码和“约定优于配置”的理念著称。此压缩包中的"rubyonrails21-cn.pdf"可能是...