奇怪的Rails 2路由问题

时间:2010-07-19 04:32:17

标签: ruby-on-rails ruby model-view-controller resources routing

我在rails 2 vs 3比较pdf讲座中看到了这一点,我不确定预览和存档标志会发生什么。

post.resources :comments, :member => { :preview => :post }, 
  :collection => { :archived => :get }

有什么想法吗?

1 个答案:

答案 0 :(得分:6)

:member => { :preview => :post}

在成员上建立另一种方法,就像这样访问:

comments/1/preview

并且只能通过邮寄方式访问。

同样,:collection => {:archived => :get}为整个集合建立了一个方法,可以通过

访问

comments/archived