SlideShare a Scribd company logo
1 of 43
Download to read offline
sub_resources
                  Rails Plugin
                  Yasuko Ohba
                     @nay3


2009年11月28日土曜日
RubyConf




                      Who I am
                 •Yasuko Ohba
                 •I love Ruby
                 •working with Ruby on
                  Rails

                 •CEO of Everyleaf
                  Corporation

                                            株式会社万葉
2009年11月28日土曜日
Everyleaf
                 Corporation



2009年11月28日土曜日
RubyConf




                 Translating
                  This Book



                                  株式会社万葉
2009年11月28日土曜日
RubyConf




                  Ruby on Rails
                 Quick Reference




                                   株式会社万葉
2009年11月28日土曜日
RubyConf




                 The first
                   time
                           株式会社万葉
2009年11月28日土曜日
RubyConf




                 sub_resources

                 •a Rails plugin

                 • it extends
                  map.resources

                                      株式会社万葉
2009年11月28日土曜日
RubyConf




                     github

                      http://
                 github.com/nay/
                  sub_resources
                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                  How many
                 people know
                  routes.rb ?



                                   株式会社万葉
2009年11月28日土曜日
RubyConf




              routes.rb
           becomes messy




                           株式会社万葉
2009年11月28日土曜日
RubyConf




                  if you need
                 RESTful URLs



                                   株式会社万葉
2009年11月28日土曜日
RubyConf




                 2 major
                 reasons


                              株式会社万葉
2009年11月28日土曜日
RubyConf




                     1. sub
                 resources in a
                   controller

                                株式会社万葉
2009年11月28日土曜日
RubyConf




                   what does
                 sub resources
                    mean?


                                株式会社万葉
2009年11月28日土曜日
RubyConf




                    examples

                 •Tags

                 • Notifications

                 • Images

                                     株式会社万葉
2009年11月28日土曜日
RubyConf




                         tags

                                 Book


                                          Author
                 Tag   Tagging

                                 Review


                                               株式会社万葉
2009年11月28日土曜日
RubyConf




                  How about
                 controllers?


                                株式会社万葉
2009年11月28日土曜日
RubyConf




                    you never
                    want this
                 •BooksTagsController
                 •AuthorsTagsController
                 • ReviewsTagsController
                 • etc...

                                         株式会社万葉
2009年11月28日土曜日
RubyConf




                              instead

                                 BooksController


                 TagService      AuthorsController


                                 ReviewsController


                                                        株式会社万葉
2009年11月28日土曜日
RubyConf




                  Not nice for
                  the regular
                 map.resources


                               株式会社万葉
2009年11月28日土曜日
RubyConf




                 Nested Resources ?

                 map.resources :books do |books|
                  books.resources :tags
                 end



                                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                  use options of
                 map.resources ?


                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                     it generates
                    strange route
                         names
                 GET /books/3/tags
                 map.resources :books,
                   :member => {:tags => :get}

                          tags_book_path
                                                   株式会社万葉
2009年11月28日土曜日
RubyConf




                   it generates
                  urls including a
                        verb
                 DELETE /books/3/destroy_tag

             map.resources :books, :member =>
              {:destroy_tag => :delete}
                     destroy_tag_book_path
                                                株式会社万葉
2009年11月28日土曜日
RubyConf




                          to fix this

                 map.book_tags 'books/:id/
                 tags', :controller => 'books', :action =>
                 'tags', :conditions => {:method => :get}

                 map.book_tag 'books/:id/
                 tag/:tag_id', :controller => 'books', :action
                 => 'destroy_tag', :conditions => {:method
                 => :delete}
                                                          株式会社万葉
2009年11月28日土曜日
RubyConf



                          for more actions,
                          more controllers
             map.book_tags 'books/:id/tags', :controller => 'books', :action => 'tags', :conditions => {:method => :get}

             map.book_tag 'books/:id/tag/:tag_id', :controller => 'books', :action => 'destroy_tag', :conditions =>
             {:method => :delete}
             map.edit_book_tags 'books/:id/tags/edit', :controller => 'books', :action => 'edit_tags', :conditions =>
             {:method => :get}
             map.connect 'books/:id/tas', :controller => 'books', :action => 'update_tags', :conditions => {:method
             => :put}

             map.author_tags 'authors/:id/tags', :controller => 'authors', :action => 'tags', :conditions => {:method
             => :get}
             map.author_tag 'authors/:id/tag/:tag_id', :controller => 'authors', :action => 'destroy_tag', :conditions =>
             {:method => :delete}
             map.edit_authors_tags 'books/:id/tags/edit', :controller => 'books', :action => 'edit_tags', :conditions =>
             {:method => :get}
             map.connect 'authors/:id/tas', :controller => 'authors', :action => 'update_tags', :conditions => {:method
             => :put}
             map.author_tags 'reviews/:id/tags', :controller => 'reviews', :action => 'tags', :conditions => {:method
             => :get}
             map.author_tag 'reviews/:id/tag/:tag_id', :controller => 'reviews', :action => 'destroy_tag', :conditions =>
             {:method => :delete}

             map.edit_book_tags 'reviews/:id/tags/edit', :controller => 'reviews', :action => 'edit_tags', :conditions =>
             {:method => :get}

             map.connect 'reviews/:id/tas', :controller => 'reviews', :action => 'update_tags', :conditions => {:method
             => :put}                                                                                             株式会社      万葉
2009年11月28日土曜日
RubyConf




                    株式会社万葉
2009年11月28日土曜日
RubyConf




                      with
                 sub_resources
                     plugin


                                株式会社万葉
2009年11月28日土曜日
RubyConf




                      simple !

                 map.resources :books,
                  :sub_resources => :tags




                                          株式会社万葉
2009年11月28日土曜日
RubyConf




                    nice mappings!
                    URL               route name    method       action
                                                      GET         tags
           /books/:id/tags            book_tags
                                                     POST      create_tag
                                                      GET         tag
           /books/:id/tags/:tag_id     book_tag       PUT      update_tag
                                                    DELETE destroy_tag

           /books/:id/tags/new       new_book_tag     GET       new_tag
           /books/:id/tags/:tag_id/edit edit_book_tag DELETE    edit_tag


                                                                    株式会社   万葉
2009年11月28日土曜日
RubyConf




                 options available
                  map.resources :books,
                   :sub_resources => {
                     :tags => {
                       :only => [:index, :delete]
                       }
                   }


                                                    株式会社万葉
2009年11月28日土曜日
RubyConf




                   single style

                 map.resources :books,
                  :sub_resource => :image




                                          株式会社万葉
2009年11月28日土曜日
RubyConf




                   2. update/
                     destroy
                 multiple records
                     at once

                                  株式会社万葉
2009年11月28日土曜日
RubyConf




                 examples



                               株式会社万葉
2009年11月28日土曜日
RubyConf




                  edit_all
                 update_all




                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                  another
                 update_all




                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                 destroy_all




                                  株式会社万葉
2009年11月28日土曜日
RubyConf




                 to delete all books
                 books
                   DELETE /books
                 destroy_all_books
                    DELETE /books/destroy_all


                 BooksController#destroy_all



                                                  株式会社万葉
2009年11月28日土曜日
RubyConf




                 with sub_resources
                      it s easy!

                     URL        method     action

                  /books/edit    GET      edit_all

                    /books       PUT     update_all

                    /books      DELETE   destroy_all


                                                      株式会社万葉
2009年11月28日土曜日
RubyConf




                     how to use
                 map.resources :books,
                  :collection => {
                    :edit_all => :get,
                    :update_all => :put,
                    :destroy_all => :delete
                   }

                                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                 also available in
                  sub resources
                     URL             name          method     action

             /books/:id/tags/edit edit_book_tags    GET      edit_tags

             /books/:id/tags                        PUT     update_tags
                                   book_tags
             /books/:id/tags                       DELETE destroy_tags




                                                                   株式会社  万葉
2009年11月28日土曜日
RubyConf




             DELETE /books/3/tags
                 BooksController#destroy_tags
                  map.resources :books,
                   :sub_resources => {
                     :tags => {
                       :collection =>
                         {:destroy_all => :delete}
                       }
                   }                                 株式会社万葉
2009年11月28日土曜日
RubyConf




                   please try &
                     enjoy it!

                      http://
                 github.com/nay/
                  sub_resources
                                     株式会社万葉
2009年11月28日土曜日

More Related Content

More from Yasuko Ohba

Good Names in Right Places on Rails
Good Names in Right Places on RailsGood Names in Right Places on Rails
Good Names in Right Places on RailsYasuko Ohba
 
名前のつけ方
名前のつけ方名前のつけ方
名前のつけ方Yasuko Ohba
 
Smell in Rails Apps (in Sapporo RubyKaigi03)
Smell in Rails Apps (in Sapporo RubyKaigi03)Smell in Rails Apps (in Sapporo RubyKaigi03)
Smell in Rails Apps (in Sapporo RubyKaigi03)Yasuko Ohba
 
The Basis of Making DSL with Ruby
The Basis of Making DSL with RubyThe Basis of Making DSL with Ruby
The Basis of Making DSL with RubyYasuko Ohba
 
More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02
More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02
More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02Yasuko Ohba
 
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009Yasuko Ohba
 
QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場
QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場
QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場Yasuko Ohba
 
テスト大嫌いっ娘のRSpec
テスト大嫌いっ娘のRSpecテスト大嫌いっ娘のRSpec
テスト大嫌いっ娘のRSpecYasuko Ohba
 
Ruby on Rails 入門
Ruby on Rails 入門Ruby on Rails 入門
Ruby on Rails 入門Yasuko Ohba
 
image_upload Plugin 2007/12/7
image_upload Plugin 2007/12/7image_upload Plugin 2007/12/7
image_upload Plugin 2007/12/7Yasuko Ohba
 
Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Yasuko Ohba
 
Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Yasuko Ohba
 
Bookscope 2007 09 07
Bookscope 2007 09 07Bookscope 2007 09 07
Bookscope 2007 09 07Yasuko Ohba
 

More from Yasuko Ohba (16)

Good Names in Right Places on Rails
Good Names in Right Places on RailsGood Names in Right Places on Rails
Good Names in Right Places on Rails
 
名前のつけ方
名前のつけ方名前のつけ方
名前のつけ方
 
Shimane2010
Shimane2010Shimane2010
Shimane2010
 
Smell in Rails Apps (in Sapporo RubyKaigi03)
Smell in Rails Apps (in Sapporo RubyKaigi03)Smell in Rails Apps (in Sapporo RubyKaigi03)
Smell in Rails Apps (in Sapporo RubyKaigi03)
 
The Basis of Making DSL with Ruby
The Basis of Making DSL with RubyThe Basis of Making DSL with Ruby
The Basis of Making DSL with Ruby
 
More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02
More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02
More Pragmatic Patterns of Ruby on Rails at Kansai Ruby Kaigi #02
 
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
 
QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場
QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場
QCon2009 Tokyo - Ruby on Railsで変わるエンタープライズ開発の現場
 
Raspbilly
RaspbillyRaspbilly
Raspbilly
 
テスト大嫌いっ娘のRSpec
テスト大嫌いっ娘のRSpecテスト大嫌いっ娘のRSpec
テスト大嫌いっ娘のRSpec
 
Shimane2008
Shimane2008Shimane2008
Shimane2008
 
Ruby on Rails 入門
Ruby on Rails 入門Ruby on Rails 入門
Ruby on Rails 入門
 
image_upload Plugin 2007/12/7
image_upload Plugin 2007/12/7image_upload Plugin 2007/12/7
image_upload Plugin 2007/12/7
 
Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子Ruby on Rails ステップアップ講座 - 大場寧子
Ruby on Rails ステップアップ講座 - 大場寧子
 
Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子Ruby on Rails 中級者を目指して - 大場寧子
Ruby on Rails 中級者を目指して - 大場寧子
 
Bookscope 2007 09 07
Bookscope 2007 09 07Bookscope 2007 09 07
Bookscope 2007 09 07
 

Recently uploaded

[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
UPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdfUPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdffurutsuka
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directoryosamut
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Danieldanielhu54
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。iPride Co., Ltd.
 
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxAtomu Hidaka
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000Shota Ito
 

Recently uploaded (9)

[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
UPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdfUPWARD_share_company_information_20240415.pdf
UPWARD_share_company_information_20240415.pdf
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
新人研修のまとめ       2024/04/12の勉強会で発表されたものです。新人研修のまとめ       2024/04/12の勉強会で発表されたものです。
新人研修のまとめ 2024/04/12の勉強会で発表されたものです。
 
20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory20240412_HCCJP での Windows Server 2025 Active Directory
20240412_HCCJP での Windows Server 2025 Active Directory
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
 
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
Amazon SES を勉強してみる その12024/04/12の勉強会で発表されたものです。
 
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptxIoT in the era of generative AI, Thanks IoT ALGYAN.pptx
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
 
PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000PHP-Conference-Odawara-2024-04-000000000
PHP-Conference-Odawara-2024-04-000000000
 

Sub Resources Rails Plug-in

  • 1. sub_resources Rails Plugin Yasuko Ohba @nay3 2009年11月28日土曜日
  • 2. RubyConf Who I am •Yasuko Ohba •I love Ruby •working with Ruby on Rails •CEO of Everyleaf Corporation 株式会社万葉 2009年11月28日土曜日
  • 3. Everyleaf Corporation 2009年11月28日土曜日
  • 4. RubyConf Translating This Book 株式会社万葉 2009年11月28日土曜日
  • 5. RubyConf Ruby on Rails Quick Reference 株式会社万葉 2009年11月28日土曜日
  • 6. RubyConf The first time 株式会社万葉 2009年11月28日土曜日
  • 7. RubyConf sub_resources •a Rails plugin • it extends map.resources 株式会社万葉 2009年11月28日土曜日
  • 8. RubyConf github http:// github.com/nay/ sub_resources 株式会社万葉 2009年11月28日土曜日
  • 9. RubyConf How many people know routes.rb ? 株式会社万葉 2009年11月28日土曜日
  • 10. RubyConf routes.rb becomes messy 株式会社万葉 2009年11月28日土曜日
  • 11. RubyConf if you need RESTful URLs 株式会社万葉 2009年11月28日土曜日
  • 12. RubyConf 2 major reasons 株式会社万葉 2009年11月28日土曜日
  • 13. RubyConf 1. sub resources in a controller 株式会社万葉 2009年11月28日土曜日
  • 14. RubyConf what does sub resources mean? 株式会社万葉 2009年11月28日土曜日
  • 15. RubyConf examples •Tags • Notifications • Images 株式会社万葉 2009年11月28日土曜日
  • 16. RubyConf tags Book Author Tag Tagging Review 株式会社万葉 2009年11月28日土曜日
  • 17. RubyConf How about controllers? 株式会社万葉 2009年11月28日土曜日
  • 18. RubyConf you never want this •BooksTagsController •AuthorsTagsController • ReviewsTagsController • etc... 株式会社万葉 2009年11月28日土曜日
  • 19. RubyConf instead BooksController TagService AuthorsController ReviewsController 株式会社万葉 2009年11月28日土曜日
  • 20. RubyConf Not nice for the regular map.resources 株式会社万葉 2009年11月28日土曜日
  • 21. RubyConf Nested Resources ? map.resources :books do |books| books.resources :tags end 株式会社万葉 2009年11月28日土曜日
  • 22. RubyConf use options of map.resources ? 株式会社万葉 2009年11月28日土曜日
  • 23. RubyConf it generates strange route names GET /books/3/tags map.resources :books, :member => {:tags => :get} tags_book_path 株式会社万葉 2009年11月28日土曜日
  • 24. RubyConf it generates urls including a verb DELETE /books/3/destroy_tag map.resources :books, :member => {:destroy_tag => :delete} destroy_tag_book_path 株式会社万葉 2009年11月28日土曜日
  • 25. RubyConf to fix this map.book_tags 'books/:id/ tags', :controller => 'books', :action => 'tags', :conditions => {:method => :get} map.book_tag 'books/:id/ tag/:tag_id', :controller => 'books', :action => 'destroy_tag', :conditions => {:method => :delete} 株式会社万葉 2009年11月28日土曜日
  • 26. RubyConf for more actions, more controllers map.book_tags 'books/:id/tags', :controller => 'books', :action => 'tags', :conditions => {:method => :get} map.book_tag 'books/:id/tag/:tag_id', :controller => 'books', :action => 'destroy_tag', :conditions => {:method => :delete} map.edit_book_tags 'books/:id/tags/edit', :controller => 'books', :action => 'edit_tags', :conditions => {:method => :get} map.connect 'books/:id/tas', :controller => 'books', :action => 'update_tags', :conditions => {:method => :put} map.author_tags 'authors/:id/tags', :controller => 'authors', :action => 'tags', :conditions => {:method => :get} map.author_tag 'authors/:id/tag/:tag_id', :controller => 'authors', :action => 'destroy_tag', :conditions => {:method => :delete} map.edit_authors_tags 'books/:id/tags/edit', :controller => 'books', :action => 'edit_tags', :conditions => {:method => :get} map.connect 'authors/:id/tas', :controller => 'authors', :action => 'update_tags', :conditions => {:method => :put} map.author_tags 'reviews/:id/tags', :controller => 'reviews', :action => 'tags', :conditions => {:method => :get} map.author_tag 'reviews/:id/tag/:tag_id', :controller => 'reviews', :action => 'destroy_tag', :conditions => {:method => :delete} map.edit_book_tags 'reviews/:id/tags/edit', :controller => 'reviews', :action => 'edit_tags', :conditions => {:method => :get} map.connect 'reviews/:id/tas', :controller => 'reviews', :action => 'update_tags', :conditions => {:method => :put} 株式会社 万葉 2009年11月28日土曜日
  • 27. RubyConf 株式会社万葉 2009年11月28日土曜日
  • 28. RubyConf with sub_resources plugin 株式会社万葉 2009年11月28日土曜日
  • 29. RubyConf simple ! map.resources :books, :sub_resources => :tags 株式会社万葉 2009年11月28日土曜日
  • 30. RubyConf nice mappings! URL route name method action GET tags /books/:id/tags book_tags POST create_tag GET tag /books/:id/tags/:tag_id book_tag PUT update_tag DELETE destroy_tag /books/:id/tags/new new_book_tag GET new_tag /books/:id/tags/:tag_id/edit edit_book_tag DELETE edit_tag 株式会社 万葉 2009年11月28日土曜日
  • 31. RubyConf options available map.resources :books, :sub_resources => { :tags => { :only => [:index, :delete] } } 株式会社万葉 2009年11月28日土曜日
  • 32. RubyConf single style map.resources :books, :sub_resource => :image 株式会社万葉 2009年11月28日土曜日
  • 33. RubyConf 2. update/ destroy multiple records at once 株式会社万葉 2009年11月28日土曜日
  • 34. RubyConf examples 株式会社万葉 2009年11月28日土曜日
  • 35. RubyConf edit_all update_all 株式会社万葉 2009年11月28日土曜日
  • 36. RubyConf another update_all 株式会社万葉 2009年11月28日土曜日
  • 37. RubyConf destroy_all 株式会社万葉 2009年11月28日土曜日
  • 38. RubyConf to delete all books books DELETE /books destroy_all_books DELETE /books/destroy_all BooksController#destroy_all 株式会社万葉 2009年11月28日土曜日
  • 39. RubyConf with sub_resources it s easy! URL method action /books/edit GET edit_all /books PUT update_all /books DELETE destroy_all 株式会社万葉 2009年11月28日土曜日
  • 40. RubyConf how to use map.resources :books, :collection => { :edit_all => :get, :update_all => :put, :destroy_all => :delete } 株式会社万葉 2009年11月28日土曜日
  • 41. RubyConf also available in sub resources URL name method action /books/:id/tags/edit edit_book_tags GET edit_tags /books/:id/tags PUT update_tags book_tags /books/:id/tags DELETE destroy_tags 株式会社 万葉 2009年11月28日土曜日
  • 42. RubyConf DELETE /books/3/tags BooksController#destroy_tags map.resources :books, :sub_resources => { :tags => { :collection => {:destroy_all => :delete} } } 株式会社万葉 2009年11月28日土曜日
  • 43. RubyConf please try & enjoy it! http:// github.com/nay/ sub_resources 株式会社万葉 2009年11月28日土曜日