Rails2.0定制action
Rubyonrails在完全接受REST思想推出2.0版本以后,action的写法与以前有了很大的不同。
一般的,index, show, new, edit, create, update,destroy默认的七个action就以足够了。但是如果有特殊要求的话,可以通过以下方法添加action。
比如在config/routes.rb有这样一个Resource:
map.resources :courses
如果要向这个resource里加一个introduce action的话,只需要在后面加上:collection。
map.resources :courses, :condition => { :introduce => :get }
:introduce即action的名称
:get是采用什么方式向server发送信息。根据需要也可以使用:post等。

