Submit Search
Upload
Railsによるurlの描き方
•
6 likes
•
2,157 views
Jun Fukaya
Follow
#sendagayarb #12で使用した。railsにおけるURLの定義方法に関する資料です。
Read less
Read more
Technology
Report
Share
Report
Share
1 of 18
Download now
Download to read offline
Recommended
知って得する標準関数の使い方
知って得する標準関数の使い方
Soudai Sone
大ざっぱにオブジェクト指向
大ざっぱにオブジェクト指向
azuma satoshi
Rails Controller Fundamentals
Rails Controller Fundamentals
Takashi SAKAGUCHI
リソースモデリングパターンの提案 #sendagayarb
リソースモデリングパターンの提案 #sendagayarb
Toru Kawamura
Railsから学ぶRESTfulなuri設計
Railsから学ぶRESTfulなuri設計
Kanako Kobayashi
Ruby on Rails3 Tutorial Chapter2
Ruby on Rails3 Tutorial Chapter2
Sea Mountain
Rails and twitter #twtr_hack
Rails and twitter #twtr_hack
i7a
OSC2008 Tokyo/Spring REST勉強夜会
OSC2008 Tokyo/Spring REST勉強夜会
Siena. N
Recommended
知って得する標準関数の使い方
知って得する標準関数の使い方
Soudai Sone
大ざっぱにオブジェクト指向
大ざっぱにオブジェクト指向
azuma satoshi
Rails Controller Fundamentals
Rails Controller Fundamentals
Takashi SAKAGUCHI
リソースモデリングパターンの提案 #sendagayarb
リソースモデリングパターンの提案 #sendagayarb
Toru Kawamura
Railsから学ぶRESTfulなuri設計
Railsから学ぶRESTfulなuri設計
Kanako Kobayashi
Ruby on Rails3 Tutorial Chapter2
Ruby on Rails3 Tutorial Chapter2
Sea Mountain
Rails and twitter #twtr_hack
Rails and twitter #twtr_hack
i7a
OSC2008 Tokyo/Spring REST勉強夜会
OSC2008 Tokyo/Spring REST勉強夜会
Siena. N
deviseを利用した認証について@Minamirb
deviseを利用した認証について@Minamirb
Jun Fukaya
はじめてのCouch db
はじめてのCouch db
Eiji Kuroda
Rails基礎講座 part.2
Rails基礎講座 part.2
Jun Yokoyama
Web技術勉強会23回目
Web技術勉強会23回目
龍一 田中
named_scope more detail - WebCareer
named_scope more detail - WebCareer
Kyosuke MOROHASHI
Ruby on Rails Tutorial
Ruby on Rails Tutorial
Ken Iiboshi
Ruby on Rails Tutorial Chapter8-10
Ruby on Rails Tutorial Chapter8-10
Sea Mountain
WordPress と Bootstrap
WordPress と Bootstrap
株式会社ガリレオ(開発グループ)
RESTとRailsスタイル
RESTとRailsスタイル
Toru Kawamura
Okinawa.rb 第2回勉強会
Okinawa.rb 第2回勉強会
Naoki Takaesu
Garageを触ってみた
Garageを触ってみた
Yoichi Toyota
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
danielhu54
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
sugiuralab
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
Toru Tamaki
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
taisei2219
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
Toru Tamaki
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
Ryo Sasaki
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
Toru Tamaki
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Yuma Ohgami
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
iPride Co., Ltd.
More Related Content
Similar to Railsによるurlの描き方
deviseを利用した認証について@Minamirb
deviseを利用した認証について@Minamirb
Jun Fukaya
はじめてのCouch db
はじめてのCouch db
Eiji Kuroda
Rails基礎講座 part.2
Rails基礎講座 part.2
Jun Yokoyama
Web技術勉強会23回目
Web技術勉強会23回目
龍一 田中
named_scope more detail - WebCareer
named_scope more detail - WebCareer
Kyosuke MOROHASHI
Ruby on Rails Tutorial
Ruby on Rails Tutorial
Ken Iiboshi
Ruby on Rails Tutorial Chapter8-10
Ruby on Rails Tutorial Chapter8-10
Sea Mountain
WordPress と Bootstrap
WordPress と Bootstrap
株式会社ガリレオ(開発グループ)
RESTとRailsスタイル
RESTとRailsスタイル
Toru Kawamura
Okinawa.rb 第2回勉強会
Okinawa.rb 第2回勉強会
Naoki Takaesu
Garageを触ってみた
Garageを触ってみた
Yoichi Toyota
Similar to Railsによるurlの描き方
(11)
deviseを利用した認証について@Minamirb
deviseを利用した認証について@Minamirb
はじめてのCouch db
はじめてのCouch db
Rails基礎講座 part.2
Rails基礎講座 part.2
Web技術勉強会23回目
Web技術勉強会23回目
named_scope more detail - WebCareer
named_scope more detail - WebCareer
Ruby on Rails Tutorial
Ruby on Rails Tutorial
Ruby on Rails Tutorial Chapter8-10
Ruby on Rails Tutorial Chapter8-10
WordPress と Bootstrap
WordPress と Bootstrap
RESTとRailsスタイル
RESTとRailsスタイル
Okinawa.rb 第2回勉強会
Okinawa.rb 第2回勉強会
Garageを触ってみた
Garageを触ってみた
Recently uploaded
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
danielhu54
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
sugiuralab
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
Toru Tamaki
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
taisei2219
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
Toru Tamaki
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
Ryo Sasaki
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
Toru Tamaki
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Yuma Ohgami
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
iPride Co., Ltd.
Recently uploaded
(9)
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
Railsによるurlの描き方
1.
RailsによるURLの描き方 fukajun@sendagaya.rb
2.
誰? ○ Jun Fukaya ○
twitter : fukajun ○ minami.rb 出身 ○ sendagaya.rb - 毎週 月曜日 コンセプト : 毎週の勉強会を楽しみにすることで 毎日の仕事やプライベートを楽しくする ○ RubyOnRails, BorneShell, Javascript, C#, PostgreSQL, MongoDB
3.
今日は何をやるの? RailsでのURLの定義する方法
↓ config/routes.rb
4.
config/routes.rbの役割 ・URLを認識させる ♥ ・URLとControllerのActionを結びつける /books/57648
→ books#show ・パラメータの定義 /maps/:latitude,:longitude
5.
URLとは? ネットワーク上のリソースを一意に指し示すもの リソースとは? ・レコード一件 ・インスタンス ・ユーザーのアカウント1件 Railsが取り扱うデータを一意に指し表すもの
6.
routes.rbでURLを作成する
URL( = リソース) に対して HTTPメソッド( = 行う操作)を決める 行う操作:どのcontrollerのaction紐付けるかを決める。
7.
HTTPメソッドの役割(get, post) リソースの取得, 参照
GET /users ミルミルー get :users, :to => "users#index" 1 2 3 users/ リソースの作成, 追加 POST /users ? post :users, :to => "users#create" 追加 1 2 3 users/
8.
HTTPメソッドの役割(put, delete)
身長: 171cm, 体重: 60kg リソースの変更 更新 1 2 3 4 PUT /users/:id users/ put 'users/:id', :to => 'users#update' リソースの削除 DELETE /users/:id delete 'users/:id', :to => 'users#destroy' 削除 1 2 3 4 users/
9.
CRUDなURLを一括で定義 (resources) GET /users
users#index GET /users/new users#new POST /users users#create GET /users/:id users#show GET /users/:id/edit edit PUT /users/:id update DELETE /users/:id destroy resources :users
10.
resourcesにURLを追加したい GET /users/friend resources
:users do get :friend, :on => :collection end GET /entries/:id/preview resources :users do get :preview, :on => :member end
11.
resourcesで定義したURLを限定する GET /users
users#index GET /users/new users#new # 不要 POST /users users#create GET /users/:id users#show GET /users/:id/edit edit # 不要 PUT /users/:id update DELETE /users/:id destroy resources :users, :only => [:index, :create, :update, : destroy] OR resources :users, :except => [:new, :edit]
12.
1つのリソースに対して CRUDなURLを一括で定義(resource) GET /profile/new
new POST /profile create GET /profile/ show GET /profile/edit edit PUT /profile update DELETE /profile destroy resource :profile, :controller => :users
13.
リソースが持っている持っている リソースへのURLを定義したい GET /posts/:post_id/comments POST /posts/:post_id/comments GET
/posts/:post_id/comments/new GET /posts/:post_id/comments/:id/edit GET /posts/:post_id/comments/:id PUT /posts/:post_id/comments/:id DELETE /posts/:post_id/comments/:id resources :posts do resources :comments end
14.
URLにprefixを付けたい場合 URL : /admin/products namespace
:admin do resource :setting, :except => [:delete] end app/controllers/admin/products_controller
15.
URLにprefixを付けたい場合 URL : /api/products scope
'/api' do resource :setting, :except => [:delete] end app/controllers/products_controller ↑ api/ディレクトリが無くても良い
16.
まとめ ● get, post,
put, deleteの役割を意識する ● resources, resourceを使うと便利 ● 従属関係にあるものは、resourcesネスト ● prefixをつけるときは、namespace, scope
17.
忘れてた GET / root :to
=> "backet#index"
18.
参考資料 ● Rails3のroutesまとめ http://irohiroki.com/2010/08/29/rails3-routes
Download now