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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
manamin0521
September 18, 2018
Programming
1
1.1k
Rails歴2年(🐥)の私が Cakeを半年触って学んだこと
コネヒトさんとのランチLTにて使用しました
manamin0521
September 18, 2018
Tweet
Share
More Decks by manamin0521
See All by manamin0521
ランサーズを支える管理画面
manamin0521
2
4.5k
Other Decks in Programming
See All in Programming
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8.1k
Docコメントで始める簡単ガードレール
keisukeikeda
1
120
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
290
[SF Ruby Feb'26] The Silicon Heel
palkan
0
100
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
140
20260315 AWSなんもわからん🥲
chiilog
2
150
Unity6.3 AudioUpdate
cova8bitdots
0
130
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
950
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
940
maplibre-gl-layers - 地図に移動体たくさん表示したい
kekyo
PRO
0
270
Codex の「自走力」を高める
yorifuji
0
1.2k
OTP を自動で入力する裏技
megabitsenmzq
0
110
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
150
Leo the Paperboy
mayatellez
4
1.5k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
140
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
85
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
140
エンジニアに許された特別な時間の終わり
watany
106
240k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
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