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
manamin0521
September 18, 2018
Programming
1
1k
Rails歴2年(🐥)の私が Cakeを半年触って学んだこと
コネヒトさんとのランチLTにて使用しました
manamin0521
September 18, 2018
Tweet
Share
More Decks by manamin0521
See All by manamin0521
ランサーズを支える管理画面
manamin0521
2
4.4k
Other Decks in Programming
See All in Programming
Web Components で実現する Hotwire とフロントエンドフレームワークの橋渡し / Bridging with Web Components
da1chi
3
1.5k
Web技術を最大限活用してRAW画像を現像する / Developing RAW Images on the Web
ssssota
2
1.1k
エンジニアとして高みを目指す、 利益を生み出す設計の考え方 / design-for-profit
minodriven
23
11k
defer f()とdefer fの挙動を 誤解していた話
kogamochiduki
2
160
Your Perfect Project Setup for Angular @BASTA! 2025 in Mainz
manfredsteyer
PRO
0
110
どの様にAIエージェントと 協業すべきだったのか?
takefumiyoshii
1
570
Advance Your Career with Open Source
ivargrimstad
0
260
タスクの特性や不確実性に応じた最適な作業スタイルの選択(ペアプロ・モブプロ・ソロプロ)と実践 / Optimal Work Style Selection: Pair, Mob, or Solo Programming.
honyanya
2
120
AIで開発生産性を上げる個人とチームの取り組み
taniigo
0
130
なぜGoのジェネリクスはこの形なのか? Featherweight Goが明かす設計の核心
ryotaros
7
1k
麻雀点数計算問題生成タスクから学ぶ Single Agentの限界と Agentic Workflowの底力
po3rin
5
2.1k
複雑化したリポジトリをなんとかした話 pipenvからuvによるモノレポ構成への移行
satoshi256kbyte
1
720
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
Building Applications with DynamoDB
mza
96
6.6k
A designer walks into a library…
pauljervisheath
208
24k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Become a Pro
speakerdeck
PRO
29
5.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
What's in a price? How to price your products and services
michaelherold
246
12k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
54
3k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
51k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
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