Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rails歴2年(🐥)の私が Cakeを半年触って学んだこと
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
manamin0521
September 18, 2018
Programming
1.1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails歴2年(🐥)の私が Cakeを半年触って学んだこと
コネヒトさんとのランチLTにて使用しました
manamin0521
September 18, 2018
More Decks by manamin0521
See All by manamin0521
ランサーズを支える管理画面
manamin0521
2
4.6k
Other Decks in Programming
See All in Programming
初めてのKubernetes 本番運用でハマった話
oku053
0
120
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
490
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4k
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
480
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
240
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
150
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
自作OSでスライド発表する
uyuki234
1
3.8k
共通化で考えるべきは、実装より公開する型だった
codeegg
0
210
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
5.8k
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
190
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
New Earth Scene 8
popppiees
3
2.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
How STYLIGHT went responsive
nonsquared
100
6.2k
The Spectacular Lies of Maps
axbom
PRO
1
850
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
170
Bash Introduction
62gerente
615
220k
The Pragmatic Product Professional
lauravandoore
37
7.4k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
180
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
600
Transcript
Rails歴2年()の私が Cakeを半年触って 学んだこと
自己紹介 松原愛美 ランサーズ株式会社1年目 CRE @manamin0521m 学生時代インターンにてRails 2
今日話すこと 2つの言語(フレームワーク)で開発したことで、 それぞれの違いを知る → 違いから気づいたことについて 3
CakePHP 1.3→2.8 PHP 5.3 Version 4
言語仕様の違い
1. viewに値を渡す時の違い Rails @user = User.find(1) Cake2.8 $user = $this->User->findById(1); $this->set(user,
$user); 6
「インスタンス変数」の認識の誤りに気づく ◂ Ruby時代は「viewに値を渡せる変数」と認識 ◂ 本来はメソッド内のみ使用可という意味 → オブジェクト指向の理解のきっかけに 7
2. 返り値の理解 Ruby def plus(num1, num2){ sum = num1 +
num2 } sum = plus(10, 8) puts '加算の結果は#{ sum }です' 最後に評価された値が返る ※指定することも可能 PHP5.3 function plus($num1, $num2){ $sum = $num1 + $num2; return $sum; } $sum = plus(10, 8); print '加算の結果は'.$sum.'です'; Returnが必要 8
3. 変数と関数の違い Ruby 変数 @user = @user.id 関数(メソッド) Post.test PHP5.3
変数 $userId = $this->User->id; 関数(メソッド) $this->Post->test(); 9
3. 変数と関数の違いを意識 ◂ PHPは関数(メソッド)を使う場合、 引数が空なら()が必要 ◂ Ruby時代はピリオドで繋ぎ、直感的に取り出していた 10
配列とオブジェクト
1. 配列の扱い方 Ruby a = [1, 2, 3] a.include?(x) a.empty?
(※Arrayクラス) PHP $a = array(1, 2, 3);(※5.3) $a = [1, 2, 3];(※5.4以降) in_array( $x, $a ); empty( $a ); 12
2. Findした結果が配列かオブジェクトか Cake2.8 Findした結果が配列 $User['id'] (3以降はオブジェクト) ※オブジェクトから値を 取り出すとき $user->id Rails
Findした結果が オブジェクト @User.id 13
3. FormからデータをPostした時の処理 Rails Paramsで受け取る createメソッドが オブジェクト化して オブジェクトをsave Cake2.8 $this->request->data; saveメソッドが
配列を引数に取るため 配列をsave 14
4. 複数テーブルを結合して値を取り出す時 Rails user = User.find(params: id) @user = user.user_profiles
オブジェクト Cake2.8 $user = $this->User->find('first', array( 'conditions' => array('User.id' => $id), 'contain' => array('UserProfile') )); $user[‘UserProfile’]; 配列 15
感じたこと Ruby時代はコピペと感覚で なんとかなってたけど PHPは省略できない部分がRubyより多い 違いの理由を学ぶことで勉強になる 複数の言語、フレームワークに触れた方がいいと言わ れる理由がわかった 16
ありがとう ございました! 17