Submit Search
Upload
バカでもわかるRails #03
•
2 likes
•
636 views
Daisuke Ishii
Follow
Ruby on Railsの難解なコンセプトを単語帳的な記憶ツールで何度も繰り返し覚える事を目的にした教材を作りました。
Read less
Read more
Technology
Report
Share
Report
Share
1 of 81
Download now
Download to read offline
Recommended
バカでもわかるRails #05
バカでもわかるRails #05
Daisuke Ishii
バカでもわかるRails #02
バカでもわかるRails #02
Daisuke Ishii
Rails for idiots #01 FlashCards for hash and CRUD
Rails for idiots #01 FlashCards for hash and CRUD
Daisuke Ishii
Rails for idiots #01 FlashCards for hash and CRUD
Rails for idiots #01 FlashCards for hash and CRUD
Daisuke Ishii
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
Daisuke Ishii
hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015
Daisuke Ishii
US Fashion Tech Trend Report
US Fashion Tech Trend Report
Daisuke Ishii
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Recommended
バカでもわかるRails #05
バカでもわかるRails #05
Daisuke Ishii
バカでもわかるRails #02
バカでもわかるRails #02
Daisuke Ishii
Rails for idiots #01 FlashCards for hash and CRUD
Rails for idiots #01 FlashCards for hash and CRUD
Daisuke Ishii
Rails for idiots #01 FlashCards for hash and CRUD
Rails for idiots #01 FlashCards for hash and CRUD
Daisuke Ishii
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
超初心者向け 無料ホームページ作成ツール Wixを学ぼう
Daisuke Ishii
hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015
Daisuke Ishii
US Fashion Tech Trend Report
US Fashion Tech Trend Report
Daisuke Ishii
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
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
More Related Content
Featured
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
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
Featured
(20)
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...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
バカでもわかるRails #03
1.
バカでもわかるRails #03 Model/View/Controller/Routes 編 石井大輔
- 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.
“books”という名前のデータベースがあると仮定しましょう。 エクセルシートに形が似ています。 id title price 1
ノルウェイの森 680 2 火花 980 3 サザエさん 540 6 *データベース名は常に小文字で始まり複数形です“books”.
7.
問: Railsが自動生成するデータベースのフィールドは 何? 7
8.
問: Railsが自動生成するデータベースのフィールドは 何? 8 答: id
/ created_at / updated_at
9.
問: 結果をBookオブジェクトの配列として返す、book テーブルからすべてのレコードを無条件に取得するアク ションは何? 9
10.
問: 結果をBookオブジェクトの配列として返す、book テーブルからすべてのレコードを無条件に取得するアク ションは何? 10 答: def
list @books = Book.all end
11.
問: 自動生成されたbook.rbのコードは何? 11
12.
問: 自動生成されたbook.rbのコードは何? 12 答: class
Book < ActiveRecord::Base end *空だが基底クラスActiveRecord::Baseがデータベースにアクセスさせてくれる
13.
問: index.json.jbuilderって何? 13
14.
問: index.json.jbuilderって何? 14 答: indexアクションの結果を JSON形式で出力する為のテン プレート
15.
問: @bookの各要素をコードで表示させてください 15
16.
問: @bookの各要素をコードで表示させてください 16 答: <% @books.each
do |book| %>
17.
問: @bookのtitleをコードで表示させてください 17
18.
問: @bookのtitleをコードで表示させてください 18 答: <%= book.title
%>
19.
問: @bookのpriceをコードで表示させてください 19
20.
問: @bookのpriceをコードで表示させてください 20 答: <%= book.price
%>
21.
問: showへのリンクをコードで表示させてください 21
22.
問: showへのリンクをコードで表示させてください 22 答: <% link_to
‘Show’, book %>
23.
問: editへのリンクをコードで表示させてください 23
24.
問: editへのリンクをコードで表示させてください 24 答: <% link_to
‘Edit’, edit_book_path(book) %> ビューヘルパー
25.
問: destroyへのリンクをコードで表示させてください 25
26.
問: destroyへのリンクをコードで表示させてください 26 答: <%
link_to ‘Destroy’, book, method: :delete, data: { confirm: ‘Are you sure?’ }%>
27.
問: new bookへのリンクをコードで表示させてください 27
28.
問: new bookへのリンクをコードで表示させてください 28 答:
<% link_to ‘New Book’, new_book_path %> ビューヘルパー
29.
問: booksパスに対応するヘルパーは? 29
30.
問: booksパスに対応するヘルパーは? 30 答: books_path
31.
問: books/:idパスに対応するヘルパーは? 31
32.
問: books/:idパスに対応するヘルパーは? 32 答: book_path(:id)
33.
問: books/newパスに対応するヘルパーは? 33
34.
問: books/newパスに対応するヘルパーは? 34 答: new_book_path
35.
問: books/:id/editパスに対応するヘルパーは? 35
36.
問: books/:id/editパスに対応するヘルパーは? 36 答: edit_book_path(id)
37.
問: paramsとは何? 37
38.
問: paramsとは何? 38 答: メソッド。params[:id]ではid パラメーターの値を取得する
39.
問: 共通フォームを表示しなさい、とうコードは何? 39
40.
問: 共通フォームを表示しなさい、とうコードは何? 40 答: <%=
render ‘form’ %> >> _form.html.erbとセットで使 われる。パーシャルという。
41.
問: form_forメソッドの使い方は? 41
42.
問: form_forメソッドの使い方は? 42 答: <%= form_for(@book)
do |f| %> @book = モデルオブジェ クト
43.
問: Bookオブジェクトを編集するフォームでtitle列に対応 するテキストボックス 43
44.
問: Bookオブジェクトを編集するフォームでtitle列に対応 するテキストボックス 44 答: <%=
f.text_field :title %>
45.
問: 新規登録画面で2つのアクションは? 45
46.
問: 新規登録画面で2つのアクションは? 46 答: new
& create
47.
問: newアクションのコードは?新規book入力のため 47
48.
問: newアクションのコードは?新規book入力のため 48 答: def
new @book = Book.new end *フォームから入力された情報を格納
49.
問: フォームからの入力値(ポストデータ)をまとめて取得 するには 49
50.
問: フォームからの入力値(ポストデータ)をまとめて取得 するには 50 答: params.require(:book). permit(:titile,
:price………)
51.
問: ハッシュとして入力した値をそのまま変数に渡して下 さい 51
52.
問: ハッシュとして入力した値をそのまま変数に渡して下 さい 52 答: @book =
Book.new (book_params)
53.
問: tweetsデータベースに対するcontroller/viewのフォ ルダ、ファイル名を答えてください 53
54.
問: tweetsデータベースに対するcontroller/viewのフォ ルダ、ファイル名を答えてください 54 答:app/controllers/tweets_controller.rb app/views/tweets/show.html.erb
55.
問: newメソッドとcreateメソッドの違いは? 55
56.
問: newメソッドとcreateメソッドの違いは? 56 答:new >>
formをrenderする getリク エスト、create >> postリクエスト
57.
問: jsonのkey値をparamsに代入するというコード 57
58.
問: jsonのkey値をparamsに代入するというコード 58 答:return render
json: params *returnを使うと以降の行は飛ばす render things in json format pass it to params key = json
59.
問: tweetのtitleを入手するためのparamsは? 59
60.
問: tweetのtitleを入手するためのparamsは? 60 答:params[:tweet][:title]
61.
問: tweetという空のオブジェクトを作ってみて 61
62.
問: tweetという空のオブジェクトを作ってみて 62 答:@tweet =
Tweet.new
63.
問: @tweetにtitleを代入してみて 63
64.
問: @tweetにtitleを代入してみて 64 答:@tweet.title =
params[: tweet][:title] 右辺が”default”だとdefaultが代 入される
65.
問: tweetsのmigrationファイルの骨格は? 65
66.
問: tweetsのmigrationファイルの骨格は? 66 答:class CreateTweets<ActiveRecord:: Migration end
67.
問: 前ページのmigrationにtitle, bodyの列を設定してみ て 67
68.
問: 前ページのmigrationにtitle, bodyの列を設定してみ て 68 答:class
CreateTweets<ActiveRecord::Migration def change create_table :tweets do |t| t.string :title t.text :body end end end 名前を変えるときは ここで変える
69.
問: migrationのtableの名前をtweetsに変えるコマンド は? 69
70.
問: migrationのtableの名前をtweetsに変えるコマンド は? 70 答:rails g
migration change_name_of_blogposts
71.
問: rollbackとは?使い方は? 71
72.
問: rollbackとは?使い方は? 72 答:前回のmigrationを取り消すこ と。rake db:rollback
73.
問: dbの初期化、再度整えて使うまでの3つのコマンドは 何? 73
74.
問: dbの初期化、再度整えて使うまでの3つのコマンドは 何? 74 答:rake db:drop rake
db:create rake db:migrate migrationはtableを使う上で必須
75.
問: index.html.erbでtweetのtitleとbodyを表示させてみ て 75
76.
問: index.html.erbでtweetのtitleとbodyを表示させてみ て 76 答:<% @tweets.each
do |tweet| %> <%= tweet.title %> <%= tweet.body %> <% end %>
77.
問: pathがわからない時はどうすれば良い? 77
78.
問: pathがわからない時はどうすれば良い? 78 答:rake routesのprefixを見る。 edit_tweet_path(tweet)
79.
問: destroy/deleteの定義をroutes上で行ってください 79
80.
問: destroy/deleteの定義をroutes上で行ってください 80 答: delete
'tweets/:id/' => "tweets#destroy", as: : destroy_tweet
81.
GOAL! よくできました! 良かったら繰り返しチャレンジしてみてください。 81 改善の為の、 ご意見ご感想お待ちしています。 Twitter@ishiid https://twitter.com/ishiid Email: dai@jenio.co
Download now