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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
170
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.1k
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
390
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
210
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.2k
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
180
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.7k
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
440
VibeCodingからAgenticWorkflowへ
starfish719
0
870
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
160
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
19k
Press start. Python's next generation.
willingc
PRO
3
130
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Git: the NoSQL Database
bkeepers
PRO
432
67k
GraphQLとの向き合い方2022年版
quramy
50
15k
Become a Pro
speakerdeck
PRO
31
6.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
670
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
300
ラッコキーワード サービス紹介資料
rakko
1
4.5M
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
450
The Curious Case for Waylosing
cassininazir
1
480
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