RoRはPUTメソッドをよく使う?
Ruby on Rails 3.0 日記の第10回に進みました。
$ rake routes (in /home/ec2-user/nchak) finish_task PUT /tasks/:id/finish(.:format) {:controller=>"tasks", :action=>"finish"} unfinish_task PUT /tasks/:id/unfinish(.:format) {:controller=>"tasks", :action=>"unfinish"} done_tasks GET /tasks/done(.:format) {:controller=>"tasks", :action=>"done"} tasks GET /tasks(.:format) {:controller=>"tasks", :action=>"index"} POST /tasks(.:format) {:controller=>"tasks", :action=>"create"}
経路の確認で上記のように表示されます。PUT, GET, POSTはHTTPのメソッドですよね。これまでGETとPOSTしか意識したことがなかったですけど普通に使っているみたい。
[追記]ブラウザが対応していないことが多いので実際にはPUTメソッドは使っていなくて、hiddenで_methodにputが設定してあるだけでした。