#35 Custom REST Actions

548 ワード

REST adds many constraints. It restricts your controllers to seven actions. Normally this is okay, but sometimes you need to add your own custom actions. Learn how in this episode.
map.resources :tasks, :collection => { :completed => :get }, :member => { :complete => :put }
<!-- tasks/index.rhtml -->
<%= link_to "Mark as complete", complete_task_path(task), :method => :put %>
...
<%= link_to "Completed Tasks", completed_tasks_path %>