Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rails歴2年(🐥)の私が Cakeを半年触って学んだこと
Search
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.7k
Other Decks in Programming
See All in Programming
速習iPhone Duo対応
yuukiw00w
2
980
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
200
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
3k
phperだってパンチカードでコーディングしたい
o0h
PRO
0
260
Kubernetes祭り #2 OP/ED
bells17
0
110
wkhtmltopdfの次どうするか問題2026
willnet
2
1.9k
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
490
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
220
The Rails Doctrine Decade
koic
2
550
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
960
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
460
Workers Cache を知る
syumai
0
350
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.8k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
610
Technical Leadership for Architectural Decision Making
baasie
3
600
Designing Experiences People Love
moore
143
24k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
980
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
770
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
450
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
WENDY [Excerpt]
tessaabrams
14
40k
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