Ruby on Rails 3 Tutorial                  Chapter 1 to 3                        @yasulab2011   9   5
Ruby on Rails 3 Tutorial                  Chapter 1 to 3                        @yasulab2011   9   5
Ruby on Rails 3 Tutorial                  Chapter 1 to 3                                 2                        @yasulab...
• Ruby on Rails 3 Tutorial chapter 1&2    • Web (Free)      • http://ruby.railstutorial.org/ruby-on-rails-tutorial-       ...
• Rails 3               •       Rspec, Git, GitHub, and Heroku           • Microblog                  Rails           • Te...
•           •   •           •2011   9   5
←   •           •   •           •2011   9   5
• 60min    • 1.    • 2.    • 3.       ok2011   9   5
2011   9   5
Rails2011   9   5
“   Rails   ”2011   9   5
2011   9   5
2011   9   5
(   )2011   9   5
2011   9   5
1.1   •           • HTML/CSS            • Head First HTML            • CSS: The Missing Manual           • Ruby           ...
1.1   •               • Railscasts               • PeeoCode, Pragmatic.tv, EnvyCasts               • Rails Guides         ...
TIPS   • Ruby Weekly    • Ruby/Rails          ML   • Minituku    • Matz2011   9   5
1.2.1   • IDE(Cross-platform): RadRails, RubyMine, 3rd Rail   • OS    • Mac OS X: TextMate, Emacs, MacVim    • Linux:Vim, ...
1.2.2   • Ruby 1.9.x, RubyGems, Rails 3.0.x, Git    • Rails3.1   • Win: Rails Installer               (?)      • http://ra...
2011   9   5
1.2.3   • mkdir rails_projecs   • cd rails_projects   • rails new first_app2011   9   5
2011   9   5
• app:               MVC   • db: DB   • public: CSS   JS   • test:   • Gemfile:2011   9   5
1.2.4   • Gemfile   • bundle install2011   9   5
1.2.5   • rails server2011   9   5
TIPS   •           “rails”   ”git”           • rails server → rails s → r s           • git → g2011   9   5
1.2.6 MVC   • app/    • models/      •    • views/      •    • controllers/      •2011   9   5
1.3 Git   • Git = (Distributed) Version Controll Systems2011   9   5
1.3 Git• git config --global user.name “Your Name”• git config --global user.email youremail@example.com• Alias  • git config...
1.3.1 Git   • git init   • emacs .gitignore    •                      →2011   9   5
1.3.2 Git   • git add .   • git status   • git commit -m “Initial commit”   • git log    • “q”2011   9   5
1.3.4 GitHub2011   9   5
1.3.4 GitHub2011   9   5
1.3.4 GitHub   •           git remote add origin git@github.com:<username>/first_app.git   •           git push origin mast...
1.3.5 Git   • Branch    • git checkout -b modify-README    • git branch   • Edit    • git mv README README.markdown    • e...
1.3.5 Git   •           Commit           •     git status           •     git commit -am “Improved the README file”   •    ...
1.4 Web                up   •           Heroku           •    sudo gem install heroku           •    heroku keys:add      ...
web   up2011   9   5
•           • 1. Rails           • 2. GitHub           • 3.          Web2011   9   5
2011   9   5
Rails2011   9   5
2.1   •           cd ~/Dropbox/rails_projects   •           rails new demo_app   •           cd demo_app   •           ema...
2.1   •           git init   •           git add .   •           git commit -m “Initial commit”   •           GitHub2011  ...
2.1   • git remote add origin                git@github.com:<username>/demo_app.git   • git push origin master2011   9   5
2.1.1 Model   •2011   9   5
2.1.1 Model   •   •2011   9   5
2.1.2 Model   • microposts    • (i.e. twitter   tweet)2011   9   5
2.1.2 Model   • microposts     • (i.e. twitter   tweet)   •   •2011   9   5
2.2 User   • rails generate scaffold User name:string email:string    •    •             db      • db      • cat db/migrat...
TIPS   • “rails generate scaffold”   •2011   9   5
TIPS   • “rails generate scaffold”   •               Rails Tutorial      .2011   9   5
TIPS   • “rails generate scaffold”   •               Rails Tutorial          .                            scaffold   .2011...
2.2   • rails s2011   9   5
2.2   • rails s2011   9   5
2.2                 click!2011   9   5
2.2                     click!2011   9   5
2.22011   9   5
2.2           click!2011   9   5
2.22011   9   5
2.22011   9   5
2.2                     click!2011   9   5
2.22011   9   5
2.2                     click!2011   9   5
2.22011   9   5
2.22011   9   5
rails generate scaffold                                         ...2011   9   5
(´-   )2011   9   5
2011   9   5
2011   9   5
2.2.2 MVC2011   9   5
2.2.2 MVC               localhost:3000/users1.                         req.2. /users index3. index            User.all4. M...
1.           req.                      +                    Enter2011   9   5
2. /users index                             app/controllers/                            users_controller.rb2011   9   5
2. /users index                             app/controllers/                            users_controller.rb2011   9   5
3. index   User.all                                app/controllers/                               users_controller.rb2011 ...
4. M db              users               5. C      users                      app/models/user.rb2011   9   5
4. M db              users               5. C      users                                           ...                    ...
6. @users users                             app/controllers/                            users_controller.rb2011   9   5
7. V   @users                               app/views/users/                                index.html.erb2011   9   5
7. V   @users                               app/views/users/                                index.html.erb2011   9   5
7. V   @users                               app/views/users/                                index.html.erb2011   9   5
8. C                       app/controllers/                      users_controller.rb2011   9   5
2.2.2 MVC               localhost:3000/users1.                         req.2. /users index3. index            User.all4. M...
...2011   9   5
app/controllers/               users_controller.rb2011   9   5
localhost:3000/users.xml                         ...   ...!?2011   9   5
2011   9   5
index2011   9   5
2011   9   5
2011   9   5
2011   9   5
URL2011   9   5
2011   9   5
2011   9   5
2011   9   5
URL2011   9   5
2011   9   5
show2011   9   5
2011   9   5
delete/update2011   9   5
2011   9   5
2011   9   5
HTTP method2011   9   5
URL       HTTP method2011   9   5
“RESTful     ”2011   9   5
TIPS   • RESTful                                chapter 12    • URL      • “GET users/1” = user No.1      • “PUT users/1” ...
RESTful2011   9   5
2011   9   5
Microposts2011   9   5
2011   9   5
2.3 Microposts   • rails generate scaffold Micropost                content:string user_id:integer   • bundle exec rake db...
2.3 Microposts2011   9   5
2.3 Microposts2011   9   5
2.3 Microposts2011   9   5
2.3 Microposts               click!2011   9   5
2.3 Microposts2011   9   5
2.3 Microposts               rails generate scaffold Micropost                content:string user_id:integer2011   9   5
2.3 Microposts               click!2011   9   5
2.3 Microposts2011   9   5
twitter-like...?2011   9   5
1.               2. User2011   9   5
2.3.22011   9   5
2.3.22011   9   5
2.3.3 User2011   9   5
2.3.3 User2011   9   5
2.3.3 User2011   9   5
2.3.3 User   • rails console   • >> User.first    • => #<User id: 1, name: “...”, email: “...” ...   • >> User.first.micropo...
2.3.3 User   • rails console   • >> User.first    • => #<User id: 1, name: “...”, email: “...” ...   • >> User.first.micropo...
2.3.3 User   • rails console   • >> User.first    • => #<User id: 1, name: “...”, email: “...” ...   • >> User.first.micropo...
2.3.3 User   • rails console   • >> User.first    • => #<User id: 1, name: “...”, email: “...” ...   • >> User.first.micropo...
2.3.3 User   • rails console   • >> User.first    • => #<User id: 1, name: “...”, email: “...” ...   • >> User.first.micropo...
2.3.3 User   • rails console   • >> User.first    • => #<User id: 1, name: “...”, email: “...” ...   • >> User.first.micropo...
2.3.5 web             up                    (   )   • git add .   • git commit -am “Done with the demo app”   • git push  ...
•           • 1. rails generate scaffold           • 2.           • 3. model2011   9   5
• Chapter 3 - Mostly static pages    • http://ruby.railstutorial.org/chapters/static-pages#top2011   9   5
Thanks!                @yasulab2011   9   5
2011   9   5
• 1.                  +    • Mac LiveDictionary+   • 2.               (i.e. 5 paragraph essay)    • Intro→body 1→body 2→bo...
Upcoming SlideShare
Loading in …5
×

Rails Tutorial ch1-2

3,803 views

Published on

Ruby on Rails 3 Tutorial の chapter 1&2 の要約です。

by @yasulab
http://flavors.me/yasulab

Published in: Technology
2 Comments
3 Likes
Statistics
Notes
No Downloads
Views
Total views
3,803
On SlideShare
0
From Embeds
0
Number of Embeds
29
Actions
Shares
0
Downloads
41
Comments
2
Likes
3
Embeds 0
No embeds

No notes for slide

Rails Tutorial ch1-2

  1. 1. Ruby on Rails 3 Tutorial Chapter 1 to 3 @yasulab2011 9 5
  2. 2. Ruby on Rails 3 Tutorial Chapter 1 to 3 @yasulab2011 9 5
  3. 3. Ruby on Rails 3 Tutorial Chapter 1 to 3 2 @yasulab2011 9 5
  4. 4. • Ruby on Rails 3 Tutorial chapter 1&2 • Web (Free) • http://ruby.railstutorial.org/ruby-on-rails-tutorial- book • • Ruby/Rails • Exercise2011 9 5
  5. 5. • Rails 3 • Rspec, Git, GitHub, and Heroku • Microblog Rails • Test-Driven Development(TDD) • Rspec red green2011 9 5
  6. 6. • • • •2011 9 5
  7. 7. ← • • • •2011 9 5
  8. 8. • 60min • 1. • 2. • 3. ok2011 9 5
  9. 9. 2011 9 5
  10. 10. Rails2011 9 5
  11. 11. “ Rails ”2011 9 5
  12. 12. 2011 9 5
  13. 13. 2011 9 5
  14. 14. ( )2011 9 5
  15. 15. 2011 9 5
  16. 16. 1.1 • • HTML/CSS • Head First HTML • CSS: The Missing Manual • Ruby • The Well-Grounded Rubyist, David A. Black • The Ruby Way, Hal Fulton2011 9 5 • The Rails 3 Way
  17. 17. 1.1 • • Railscasts • PeeoCode, Pragmatic.tv, EnvyCasts • Rails Guides • Rails blogs2011 9 5
  18. 18. TIPS • Ruby Weekly • Ruby/Rails ML • Minituku • Matz2011 9 5
  19. 19. 1.2.1 • IDE(Cross-platform): RadRails, RubyMine, 3rd Rail • OS • Mac OS X: TextMate, Emacs, MacVim • Linux:Vim, gedit+GMate, Kate • Win:Vim, E Text Editor, Komodo Edit, Sublime Text • Browswers: • Firefox + Firebug • Firebug Lite2011 9 5
  20. 20. 1.2.2 • Ruby 1.9.x, RubyGems, Rails 3.0.x, Git • Rails3.1 • Win: Rails Installer (?) • http://railsinstaller.org • Mac&Linux: • http://ruby.railstutorial.org/ruby-on-rails-tutorial- book#sec:rubygems2011 9 5
  21. 21. 2011 9 5
  22. 22. 1.2.3 • mkdir rails_projecs • cd rails_projects • rails new first_app2011 9 5
  23. 23. 2011 9 5
  24. 24. • app: MVC • db: DB • public: CSS JS • test: • Gemfile:2011 9 5
  25. 25. 1.2.4 • Gemfile • bundle install2011 9 5
  26. 26. 1.2.5 • rails server2011 9 5
  27. 27. TIPS • “rails” ”git” • rails server → rails s → r s • git → g2011 9 5
  28. 28. 1.2.6 MVC • app/ • models/ • • views/ • • controllers/ •2011 9 5
  29. 29. 1.3 Git • Git = (Distributed) Version Controll Systems2011 9 5
  30. 30. 1.3 Git• git config --global user.name “Your Name”• git config --global user.email youremail@example.com• Alias • git config --global alias.$( ) • git config --global alias.a add • git config --global alias.c commit • git config --global alias.r remote• : git config --global core.editor “emacs”2011 9 5
  31. 31. 1.3.1 Git • git init • emacs .gitignore • →2011 9 5
  32. 32. 1.3.2 Git • git add . • git status • git commit -m “Initial commit” • git log • “q”2011 9 5
  33. 33. 1.3.4 GitHub2011 9 5
  34. 34. 1.3.4 GitHub2011 9 5
  35. 35. 1.3.4 GitHub • git remote add origin git@github.com:<username>/first_app.git • git push origin master2011 9 5
  36. 36. 1.3.5 Git • Branch • git checkout -b modify-README • git branch • Edit • git mv README README.markdown • emacs README.markdown2011 9 5
  37. 37. 1.3.5 Git • Commit • git status • git commit -am “Improved the README file” • Merge • git checkout master • git merge modify-README • Branch delete • git branch -d modify-README • Push2011 9 • 5 git push
  38. 38. 1.4 Web up • Heroku • sudo gem install heroku • heroku keys:add • heroku create • git push heroku master • heroku open • (Option) Heroku App URL • heroku rename okinawarb-railstutorial2011 9 5
  39. 39. web up2011 9 5
  40. 40. • • 1. Rails • 2. GitHub • 3. Web2011 9 5
  41. 41. 2011 9 5
  42. 42. Rails2011 9 5
  43. 43. 2.1 • cd ~/Dropbox/rails_projects • rails new demo_app • cd demo_app • emacs Gemfile •2011 9 5 bundle install
  44. 44. 2.1 • git init • git add . • git commit -m “Initial commit” • GitHub2011 9 5
  45. 45. 2.1 • git remote add origin git@github.com:<username>/demo_app.git • git push origin master2011 9 5
  46. 46. 2.1.1 Model •2011 9 5
  47. 47. 2.1.1 Model • •2011 9 5
  48. 48. 2.1.2 Model • microposts • (i.e. twitter tweet)2011 9 5
  49. 49. 2.1.2 Model • microposts • (i.e. twitter tweet) • •2011 9 5
  50. 50. 2.2 User • rails generate scaffold User name:string email:string • • db • db • cat db/migrate/< >_create_users.rb • bundle exec rake db:migrate • db2011 9 5
  51. 51. TIPS • “rails generate scaffold” •2011 9 5
  52. 52. TIPS • “rails generate scaffold” • Rails Tutorial .2011 9 5
  53. 53. TIPS • “rails generate scaffold” • Rails Tutorial . scaffold .2011 9 5
  54. 54. 2.2 • rails s2011 9 5
  55. 55. 2.2 • rails s2011 9 5
  56. 56. 2.2 click!2011 9 5
  57. 57. 2.2 click!2011 9 5
  58. 58. 2.22011 9 5
  59. 59. 2.2 click!2011 9 5
  60. 60. 2.22011 9 5
  61. 61. 2.22011 9 5
  62. 62. 2.2 click!2011 9 5
  63. 63. 2.22011 9 5
  64. 64. 2.2 click!2011 9 5
  65. 65. 2.22011 9 5
  66. 66. 2.22011 9 5
  67. 67. rails generate scaffold ...2011 9 5
  68. 68. (´- )2011 9 5
  69. 69. 2011 9 5
  70. 70. 2011 9 5
  71. 71. 2.2.2 MVC2011 9 5
  72. 72. 2.2.2 MVC localhost:3000/users1. req.2. /users index3. index User.all4. M db users5. C users6. @users users7. V @users8. C2011 9 5
  73. 73. 1. req. + Enter2011 9 5
  74. 74. 2. /users index app/controllers/ users_controller.rb2011 9 5
  75. 75. 2. /users index app/controllers/ users_controller.rb2011 9 5
  76. 76. 3. index User.all app/controllers/ users_controller.rb2011 9 5
  77. 77. 4. M db users 5. C users app/models/user.rb2011 9 5
  78. 78. 4. M db users 5. C users ... app/models/user.rb2011 9 5
  79. 79. 6. @users users app/controllers/ users_controller.rb2011 9 5
  80. 80. 7. V @users app/views/users/ index.html.erb2011 9 5
  81. 81. 7. V @users app/views/users/ index.html.erb2011 9 5
  82. 82. 7. V @users app/views/users/ index.html.erb2011 9 5
  83. 83. 8. C app/controllers/ users_controller.rb2011 9 5
  84. 84. 2.2.2 MVC localhost:3000/users1. req.2. /users index3. index User.all4. M db users5. C users6. @users users7. V @users8. C2011 9 5
  85. 85. ...2011 9 5
  86. 86. app/controllers/ users_controller.rb2011 9 5
  87. 87. localhost:3000/users.xml ... ...!?2011 9 5
  88. 88. 2011 9 5
  89. 89. index2011 9 5
  90. 90. 2011 9 5
  91. 91. 2011 9 5
  92. 92. 2011 9 5
  93. 93. URL2011 9 5
  94. 94. 2011 9 5
  95. 95. 2011 9 5
  96. 96. 2011 9 5
  97. 97. URL2011 9 5
  98. 98. 2011 9 5
  99. 99. show2011 9 5
  100. 100. 2011 9 5
  101. 101. delete/update2011 9 5
  102. 102. 2011 9 5
  103. 103. 2011 9 5
  104. 104. HTTP method2011 9 5
  105. 105. URL HTTP method2011 9 5
  106. 106. “RESTful ”2011 9 5
  107. 107. TIPS • RESTful chapter 12 • URL • “GET users/1” = user No.1 • “PUT users/1” = user No.1 • “DELETE users/1” = user No.1 • API . • HTTP method2011 9 5
  108. 108. RESTful2011 9 5
  109. 109. 2011 9 5
  110. 110. Microposts2011 9 5
  111. 111. 2011 9 5
  112. 112. 2.3 Microposts • rails generate scaffold Micropost content:string user_id:integer • bundle exec rake db:migrate2011 9 5
  113. 113. 2.3 Microposts2011 9 5
  114. 114. 2.3 Microposts2011 9 5
  115. 115. 2.3 Microposts2011 9 5
  116. 116. 2.3 Microposts click!2011 9 5
  117. 117. 2.3 Microposts2011 9 5
  118. 118. 2.3 Microposts rails generate scaffold Micropost content:string user_id:integer2011 9 5
  119. 119. 2.3 Microposts click!2011 9 5
  120. 120. 2.3 Microposts2011 9 5
  121. 121. twitter-like...?2011 9 5
  122. 122. 1. 2. User2011 9 5
  123. 123. 2.3.22011 9 5
  124. 124. 2.3.22011 9 5
  125. 125. 2.3.3 User2011 9 5
  126. 126. 2.3.3 User2011 9 5
  127. 127. 2.3.3 User2011 9 5
  128. 128. 2.3.3 User • rails console • >> User.first • => #<User id: 1, name: “...”, email: “...” ... • >> User.first.microposts • => [#<Micropost id: 1, content: “...”, ...2011 9 5
  129. 129. 2.3.3 User • rails console • >> User.first • => #<User id: 1, name: “...”, email: “...” ... • >> User.first.microposts • => [#<Micropost id: 1, content: “...”, ...2011 9 5
  130. 130. 2.3.3 User • rails console • >> User.first • => #<User id: 1, name: “...”, email: “...” ... • >> User.first.microposts • => [#<Micropost id: 1, content: “...”, ...2011 9 5
  131. 131. 2.3.3 User • rails console • >> User.first • => #<User id: 1, name: “...”, email: “...” ... • >> User.first.microposts • => [#<Micropost id: 1, content: “...”, ...2011 9 5
  132. 132. 2.3.3 User • rails console • >> User.first • => #<User id: 1, name: “...”, email: “...” ... • >> User.first.microposts • => [#<Micropost id: 1, content: “...”, ...2011 9 5
  133. 133. 2.3.3 User • rails console • >> User.first • => #<User id: 1, name: “...”, email: “...” ... • >> User.first.microposts • => [#<Micropost id: 1, content: “...”, ...2011 9 5
  134. 134. 2.3.5 web up ( ) • git add . • git commit -am “Done with the demo app” • git push • heroku create • git push heroku master • heroku rake db:migrate • heroku open2011 9 5
  135. 135. • • 1. rails generate scaffold • 2. • 3. model2011 9 5
  136. 136. • Chapter 3 - Mostly static pages • http://ruby.railstutorial.org/chapters/static-pages#top2011 9 5
  137. 137. Thanks! @yasulab2011 9 5
  138. 138. 2011 9 5
  139. 139. • 1. + • Mac LiveDictionary+ • 2. (i.e. 5 paragraph essay) • Intro→body 1→body 2→body 3→cncl. • 3. •“ ”2011 9 5
  140. 140. jQuery Plugin • gem jquery-rails • bundle install • rails generate jquery:install --ui2011 9 5

×