Submit Search
Upload
バカでもわかるRails #05
•
0 likes
•
676 views
Daisuke Ishii
Follow
Ruby on Railsの難解なコンセプトを、クイズ形式の単語帳的な仕組みで繰り返し覚え、理解をはやめる事を目的とした教材です。
Read less
Read more
Technology
Report
Share
Report
Share
1 of 93
Download now
Download to read offline
Recommended
Rails for idiots #01 FlashCards for hash and CRUD
Rails for idiots #01 FlashCards for hash and CRUD
Daisuke Ishii
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
Daisuke Ishii
バカでもわかるRails #02
バカでもわかるRails #02
Daisuke Ishii
バカでもわかるRails #03
バカでもわかるRails #03
Daisuke Ishii
Rails初心者レッスン lesson4 2edition
Rails初心者レッスン lesson4 2edition
Satomi Tsujita
マルチスレッド学習のミッシングリンク
マルチスレッド学習のミッシングリンク
Satoshi KOBAYASHI
Web技術勉強会 20110723
Web技術勉強会 20110723
龍一 田中
Start!! Ruby
Start!! Ruby
mitim
Recommended
Rails for idiots #01 FlashCards for hash and CRUD
Rails for idiots #01 FlashCards for hash and CRUD
Daisuke Ishii
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
Daisuke Ishii
バカでもわかるRails #02
バカでもわかるRails #02
Daisuke Ishii
バカでもわかるRails #03
バカでもわかるRails #03
Daisuke Ishii
Rails初心者レッスン lesson4 2edition
Rails初心者レッスン lesson4 2edition
Satomi Tsujita
マルチスレッド学習のミッシングリンク
マルチスレッド学習のミッシングリンク
Satoshi KOBAYASHI
Web技術勉強会 20110723
Web技術勉強会 20110723
龍一 田中
Start!! Ruby
Start!! Ruby
mitim
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
atsushi061452
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
keikoitakurag
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
ssuserbefd24
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
yassun7010
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
iPride Co., Ltd.
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
atsushi061452
20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf
Ayachika Kitazaki
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
Sony - Neural Network Libraries
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
NTT DATA Technology & Innovation
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
CRI Japan, Inc.
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
More Related Content
Recently uploaded
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
atsushi061452
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
keikoitakurag
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
ssuserbefd24
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
yassun7010
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
iPride Co., Ltd.
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
atsushi061452
20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf
Ayachika Kitazaki
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
Sony - Neural Network Libraries
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
NTT DATA Technology & Innovation
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
CRI Japan, Inc.
Recently uploaded
(10)
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
バカでもわかるRails #05
1.
バカでもわかるRails #05 Model/ActiveRecord/Database 編 石井大輔
- www.jenio.co Twitter@ishiid, email: dai@jenio.co 1 馬鹿
2.
パパ、 Ruby on Rails教えて! 2
3.
題名はクレージーですが、真面目な教材です Rubyは英語みたいでとっつきやすいのに、Railsはとても難しい。 これが初心者の僕の悩みでした。もっと簡単な学習方法はないものか。 原因はRails用語が実生活で全く使わない抽象概念だからではないでしょうか。 だったらまず用語の意味を繰り返し覚えるべきでは? 英語の勉強と同じ手法を取れば良いのでは?これが僕の仮説です。 Q&A形式でクイズっぽい単語帳カードを作りましたので、 自習もしくは相方と使ってみて下さい。 コーディングを楽しみましょう! 3
4.
単語帳の様に繰り返し学びましょう! 4
5.
注意 この教材は一通りRailsを勉強したが、 記憶が定着していない人を対象としています。 全くの初心者の方は、 まずRubyとRailsを勉強し、補助教材として使ってください。 説明を意図的にシンプルかつ抽象的にまとめてありますので、 細かい点気になる人はググりましょう。 5
6.
Active Recordを 勉強しよう! 6
7.
問: ActiveRecordとは何? 7
8.
問: ActiveRecordとは何? 8 答: リレーショナルデータベース向けのデザインパ ターン。データを静的な行としてではなく、動的なオブ ジェクトとして捉える。
9.
問: ActiveRecordはどう賢いのか? 9
10.
問: ActiveRecordはどう賢いのか? 10 答: tableの構造を理解している。tableの行のデー タを持っている。Create/Read/Update/Deleteとい う動きをわかっている。オブジェクトとして取り扱い、 保存が簡単。
11.
問: ActiveRecordを使ってUserクラスにKevinを加える コードは? 11
12.
問: ActiveRecordを使ってUserクラスにKevinを加える コードは? 12 答: user
= User.new #空のユーザー user.first_name = “Kevin” user.save
13.
問: ActiveRecordを使ってUserクラスに同様にlast name -
Smith加えるコードは? 13
14.
問: ActiveRecordを使ってUserクラスに同様にlast name -
Smith加えるコードは? 14 答: user.last_name = “Smith” user.save
15.
問: 前ページのデータを消去するコード 15
16.
問: 前ページのデータを消去するコード 16 答: user.delete
17.
Active Relationを 勉強しよう! 17
18.
問: ActiveRelationとは何か?略称は? 18
19.
問: ActiveRelationとは何か?略称は? 19 答: ARel。オブジェクト指向のリレーショナル Algebra(代数)
20.
問: ActiveRelationは何が便利か? 20
21.
問: ActiveRelationは何が便利か? 21 答: 複雑だったDatabase問い合わせをシンプルに する。小さな問い合わせをつなげる。SQLを使って 問い合わせを繋げたりまとめたりできる。必要な時 のみ問合せさせればよい。
22.
問: ActiveRelationの事例をいくつか示しなさい 22
23.
問: ActiveRelationの事例をいくつか示しなさい 23 答: users
= User.where(:first_name => “Kevin”) users = users.order(“last_name ASC”).limit(5) users = users.include(:articles_authored)
24.
Modelを 勉強しよう! 24
25.
問: Modelのクラス名は大文字? 25
26.
問: Modelのクラス名は大文字? 26 答: SingularName
(Camel Case)
27.
問: Modelのファイル名は大文字? 27
28.
問: Modelのファイル名は大文字? 28 答: singular_name.rb
(Snake Case)
29.
問: Modelを生成しなさい。単数形複数形に気をつけて。 29
30.
問: Modelを生成しなさい。単数形複数形に気をつけて。 30 答: rails
generate model SingularName (=大文 字単数形)
31.
問: Modelはどんなファイルですか? 31
32.
問: Modelはどんなファイルですか? 32 答: app/models/subject.rb
class名:Subject 継 承:ActiveRecord ファイル名、クラス名、table名に 注意
33.
問: app/models/user.rbの中身は? 33
34.
問: app/models/user.rbの中身は? 34 答: class
User < ActiveRecord::Base self.table_name = “admin_users” end
35.
問: admin_user.rbモデルのコードの骨格は? 35
36.
問: admin_user.rbモデルのコードの骨格は? 36 答: class
User < ActiveRecord::Base end
37.
問: 前ページの続きで、first_name, last_nameにアクセ スするコードは? 37
38.
問: 前ページの続きで、first_name, last_nameにアクセ スするコードは? 38 答:
attr_accessor :first_name attr_accessor :last_name
39.
Rails Consoleを 勉強しよう! 39
40.
問: irbとは? 40
41.
問: irbとは? 41 答: interactive
ruby。Rubyの簡易入力形式。
42.
問: consoleでsubjectというvalueを作ってください 42
43.
問: consoleでsubjectというvalueを作ってください 43 答: subject
= Subject.new (空のデータ)
44.
問: consoleでsubjectにKevinというvalueを代入して下 さい 44
45.
問: consoleでsubjectにKevinというvalueを代入して下 さい 45 答: subject.name
= “Kevin”
46.
問: consoleでKevinを表示させて下さい 46
47.
問: consoleでKevinを表示させて下さい 47 答: subject.name
48.
問: 本番環境のconsoleを立ち上げてください 48
49.
問: 本番環境のconsoleを立ち上げてください 49 答: rails
console production
50.
問: consoleでいうNew/Saveとはどんな作業ですか? 50
51.
問: consoleでいうNew/Saveとはどんな作業ですか? 51 答: オブジェクトのインスタンス化>Valueの設定>保 存
52.
問: 前ページの作業をsubjectとコードで表現してください 52
53.
問: 前ページの作業をsubjectとコードで表現してください 53 答: subject
= Subject.new (インスタンス化) subject.new_record? >> true(保存前) subject.name = “First Subject” subject.save >>> true (保存終了) subject.id >>> 1
54.
問: consoleでいうCreateとはどんな作業ですか? 54
55.
問: consoleでいうCreateとはどんな作業ですか? 55 答: オブジェクトのインスタンス化+Valueの設定+保 存を一度にやる事
56.
問: 前ページの作業をsubjectとコードで表現してください 56
57.
問: 前ページの作業をsubjectとコードで表現してください 57 答: subject
= Subject.create( : name => “Second Subject”, :position => “2” ) subject (保存済)
58.
問: consoleでいうFind/Saveとはどんな作業ですか? 58
59.
問: consoleでいうFind/Saveとはどんな作業ですか? 59 答: 記録を見つける>>Valueの設定>>保存する
60.
問: 前ページの作業をsubjectとコードで表現してください 60
61.
問: 前ページの作業をsubjectとコードで表現してください 61 答: subject.new_record?
>> false(保存済) subject.name = “Initial Subject”(上書き) subject.save >>> true (保存終了) subject >>> “Initial Subject”
62.
問: consoleでいうFind/update_attributeとはどんな作業 ですか? 62
63.
問: consoleでいうFind/update_attributeとはどんな作業 ですか? 63 答: 記録を見つける>>Valueの設定+保存するを 一度にやる
64.
問: 前ページの作業をsubjectとコードで表現してください 64
65.
問: 前ページの作業をsubjectとコードで表現してください 65 答: subject
= Subject.find(2) subject.update_attributes( :name=> “Next Subject”, :visible => true )
66.
問: consoleでいうdelete/destroyはどっちが正しい? 66
67.
問: consoleでいうdelete/destroyはどっちが正しい? 67 答: 厳密にはdestroyを使うべき。deleteは推薦しな い。
68.
問: consoleでいうFind/destroyとはどんな作業ですか? 68
69.
問: consoleでいうFind/destroyとはどんな作業ですか? 69 答: 記録を見つける>>データを破壊する
70.
問: bad subjectを3番目のデータとして作って、破壊してく ださい 70
71.
問: bad subjectを3番目のデータとして作って、破壊してく ださい 71 答:
subject.create(:name => “Bad Subject”) subject = Subject.find(3) subject.destroy (not delete!) subject >> nil
72.
Databaseを 組み立てよう! 72
73.
問: 新しいDatabaseを組み立てる順番は? 73
74.
問: 新しいDatabaseを組み立てる順番は? 74 答: migration
>> model (has_many/belongs_to) >> controller >> view
75.
問: Migrationでデータを積み直すコマンドは? 75
76.
問: Migrationでデータを積み直すコマンドは? 76 答: reload!
77.
問: blogpostに最初の値を代入してください 77
78.
問: blogpostに最初の値を代入してください 78 答: blogpost
= Blogpost.first
79.
問: 前ページのblogpostにcommentデータを追加してくだ さい 79
80.
問: 前ページのblogpostにcommentデータを追加してくだ さい 80 答: blogpost.comments.build
(空データ) blogpost.comments.save (保存)
81.
問: bにそれぞれの@blogpostを実行し代入するコードは 何? 81
82.
問: bにそれぞれの@blogpostを実行し代入するコードは 何? 82 答: <%
@blogpost.each do |b| %>
83.
問:blogpostに付随したcommentを入力するフォームの コードは何? 83
84.
問:blogpostに付随したcommentを入力するフォームの コードは何? 84 答: <%= form_for
[blogpost, blogpost. comments.build] do |c| %>
85.
問:blogpostsに付随したcomments Databaseを参照す るためのroutes.rbは何? 85
86.
問:blogpostsに付随したcomments Databaseを参照す るためのroutes.rbは何? 86 答: resources
:blogposts do resources :comments end
87.
問:createメソッド中で、json形式でパラメーターを表示さ せて下さい 87
88.
問:createメソッド中で、json形式でパラメーターを表示さ せて下さい 88 答: def create return
render json: params end
89.
問:migrationの列の項目が間違っていた時の修正方法 89
90.
問:migrationの列の項目が間違っていた時の修正方法 90 答: a) rake
db:rollback >> rake db:migrate b) reload! コマンド
91.
問:comments tableのbody列のデータを取得するコード 91
92.
問:comments tableのbody列のデータを取得するコード 92 答: params[:comment][:body]
>>> return “nice post”
93.
GOAL! よくできました! 良かったら繰り返しチャレンジしてみてください。 93 改善の為の、 ご意見ご感想お待ちしています。 Twitter@ishiid https://twitter.com/ishiid Email: dai@jenio.co
Download now