Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails Workshop

Mike Skalnik
February 20, 2012

Rails Workshop

Slides for a Ruby on Rails workshop I gave at Georgia Tech. Script available: https://gist.github.com/1876817

Mike Skalnik

February 20, 2012
Tweet

More Decks by Mike Skalnik

Other Decks in Programming

Transcript

  1. Rails is a web framework Monday, February 20, 12 A

    full stack framework for creating database backed web apps
  2. Rails is a kitchen sink Monday, February 20, 12 Tries

    to include all the things you need
  3. Rails is not a silver bullet Monday, February 20, 12

    Rails makes it easy to make a web application quickly. A fantastic starting place. *Agile*
  4. Rails is opinionated Monday, February 20, 12 * Reaching for

    copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it
  5. •Don’t Repeat Yourself (DRY) Rails is opinionated Monday, February 20,

    12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it
  6. •Don’t Repeat Yourself (DRY) •Convention over Configuration Rails is opinionated

    Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it
  7. •Don’t Repeat Yourself (DRY) •Convention over Configuration •Keep It Simple

    Stupid Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it
  8. •Don’t Repeat Yourself (DRY) •Convention over Configuration •Keep It Simple

    Stupid •You Aren’t Gonna Need It Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it
  9. Rails has Monday, February 20, 12 * ActiveRecord * ActionView

    (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD
  10. Rails has •An Object Relational Mapper Monday, February 20, 12

    * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD
  11. Rails has •An Object Relational Mapper •A Templating Engine Monday,

    February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD
  12. Rails has •An Object Relational Mapper •A Templating Engine •Web

    Application Conventions Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD
  13. Rails has •An Object Relational Mapper •A Templating Engine •Web

    Application Conventions •An internal Ruby DSL Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD
  14. Rails has •An Object Relational Mapper •A Templating Engine •Web

    Application Conventions •An internal Ruby DSL •Testing built in Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD
  15. Lets chat about MVC Monday, February 20, 12 What do

    you guys know about MVC? Technically Model2
  16. Model “Models” the nouns in your application Responsible for behavior

    & data The posts, comments, and authors Monday, February 20, 12
  17. View Displays information passed to it HTML, XML, or even

    complex JSON Templated with erb, builder, slim Monday, February 20, 12
  18. Controller Browser View Model Monday, February 20, 12 Browser sends

    request which controller sees Controller coordinates with Model Passes values to view View renders values and sends to browser Terminal time!
  19. ActiveRecord “An object that wraps a row in a database

    table” Monday, February 20, 12 Based on Martin Fowler’s Active Record
  20. Usage Create create, new Read find, find_by_<attr> Update save, update_attributes

    Delete destroy Monday, February 20, 12 Create instantiates and saves, new only instantiates find_by_attr
  21. Usage Pass to view as @var redirect_to render Monday, February

    20, 12 redirect_to sends a 301 and redirects to different action render just renders that actions view
  22. ERB <% %> Evaluate <%= %> Evaluate & Print <%-

    %> Evaluate & Eat Whitespace Monday, February 20, 12