Intro to Rails

661 views
551 views

Published on

LVRUG meetup

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
661
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Intro to Rails

  1. 1. Agile Web Development<br />with Rails (for 3.1)<br />Ya, that book<br />@LVRUG - Jeremy Woertink<br />
  2. 2. What is "Rails" you ask?<br />"Ruby on Rails is a framework that makes it easier to develop, deploy, and maintain web applications."<br />"Rails applications are written in Ruby, a modern, object-oriented scripting language."<br />
  3. 3. What is "Rails" you ask?<br /><ul><li>Web Development Framework
  4. 4. MVC Architecture
  5. 5. Written in Ruby
  6. 6. Convention over Configuration
  7. 7. RESTful
  8. 8. Agile
  9. 9. Clean</li></ul> more info given in the Introduction section<br />
  10. 10. Who uses it?<br />
  11. 11. Websites on Rails<br /><ul><li>Yellow Pages
  12. 12. Groupon
  13. 13. Living Social
  14. 14. Github
  15. 15. Funny or Die!
  16. 16. Pololu
  17. 17. Cardplayer
  18. 18. ScripSmart
  19. 19. and lots of Russ's pr0n....</li></li></ul><li>Where's the start button?<br />
  20. 20. Installation<br />You're in luck, it's a gem! :)<br />$ sudo gem install rails<br />sudo may not be needed...<br />
  21. 21. Checklist<br /><ul><li>Know what it is? CHECK</li></li></ul><li>Checklist<br /><ul><li>Know what it is? CHECK
  22. 22. Know who uses it? CHECK</li></li></ul><li>Checklist<br /><ul><li>Know what it is? CHECK
  23. 23. Know who uses it? CHECK
  24. 24. Know where to get it? CHECK</li></li></ul><li>Checklist<br /><ul><li>Know what it is? CHECK
  25. 25. Know who uses it? CHECK
  26. 26. Know where to get it? CHECK
  27. 27. Know how to use it? NOPE. Chuck Testa</li></li></ul><li>Gettin' REAL dirty<br />$ cd websites<br />websites$ rails new demo <br />create lots of stuff<br />run bundle install<br /> Fetching source index for http://rubygems.org/<br />Your bundle is complete!<br />websites$ cd demo<br />demo$ rails server<br />=> Booting WEBrick <br />=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000<br />
  28. 28. http://localhost:3000<br />
  29. 29. Hello, Rails!<br />demo$ rails generate controller Say hello goodbye<br />create more stuff...<br />invoke things<br />route whatever<br />
  30. 30. Hello, Rails!<br />demo$ rails generate controller Say hello goodbye<br />create more stuff...<br />invoke things<br />route whatever<br />Visit http://localhost:3000/say/hello<br />
  31. 31. ZOMG! What happened?<br /><ul><li>created "SayController"
  32. 32. app/controllers/say_controller.rb
  33. 33. created views for "say"
  34. 34. app/views/say/hello.html.erb
  35. 35. app/views/say/goodbye.html.erb
  36. 36. updated routes with "say" routes
  37. 37. config/routes.rb
  38. 38. created other super secret squirrel stuff (i.e. assets, tests, helper)</li></li></ul><li>app/controllers/say_controller.rb<br />classSayController < ApplicationController<br />defhello<br />end<br />defgoodbye<br /> end<br />end<br />
  39. 39. app/controllers/say_controller.rb<br />
  40. 40. app/views/say/hello.html.erb<br /><ul><li>say - The name of the controller
  41. 41. hello - The name of the action
  42. 42. html - The end format we want
  43. 43. js, xml, text...
  44. 44. erb - The ruby templating system
  45. 45. haml, slim, mustache, liquid...</li></li></ul><li>app/views/say/hello.html.erb<br /><h1>Say#hello</h1><br /><p>Find me in app/views/say/hello.html.erb</p><br />
  46. 46. app/views/say/hello.html.erb<br /><h1>Hello from Rails!</h1><br /><p>It is now <%= Time.now %></p><br />
  47. 47. http://localhost:3000/say/hello<br />
  48. 48. app/controllers/say_controller.rb<br />classSayController < ApplicationController<br />defhello<br />@time =Time.now<br />end<br />defgoodbye<br /> end<br />end<br />
  49. 49. app/views/say/hello.html.erb<br /><h1>Hello from Rails!</h1><br /><p>It is now <%= @time %></p><br />
  50. 50. Fancy pants time!<br />
  51. 51. app/views/say/hello.html.erb<br /><h1>Hello from Rails!</h1><br /><p>It is now <%= @time %></p><br /><p><br />Time to say<br /><%= link_to("Goodbye", say_goodbye_path) %>!<br /></p><br />
  52. 52. http://localhost:3000/say/hello<br />
  53. 53. app/views/say/goodbye.html.erb<br /><h1>Say#goodbye</h1><br /><p>Find me in app/views/say/goodbye.html.erb</p><br />
  54. 54. app/views/say/goodbye.html.erb<br /><h1>Beer time?</h1><br /><blink>Holla atchya boy!</blink><br /><span><br />Say<br /><%= link_to("Hello", say_hello_path) %> again.<br /></span><br />
  55. 55. app/views/say/goodbye.html.erb<br /><h1>Beer time?</h1><br /><blink>Holla atchya boy!</blink><br /><span><br />Say<br /><%= link_to("Hello", say_hello_path) %> again.<br /></span><br />ahh yeah, you love the blink tag don't ya!<br />
  56. 56. Recapitulation time!<br /><ul><li>Installed rails
  57. 57. Created a new application
  58. 58. Generated controller and views
  59. 59. Added dynamic content
  60. 60. Linked pages together</li></li></ul><li>Questions?!<br />

×