Ruby on Rails: An introduction - Who am I? RoR: An introduction Presented by: Maciej Mensfeld senior ruby [email protected] lead ruby [email protected] [email protected] dev.mensfeld.pl github.com/mensfeld Maciej Mensfeld Ruby on Rails: An introduction - Rules RoR: An introduction Please… • …ask me to slow down, if I speak to quickly; • …ask me again, if I forget; • …ask questions, if anything i say is not clear; • …feel free to share your own observations Maciej Mensfeld 2/30 Ruby on Rails: An introduction – Rails what? RoR: An introduction Maciej Mensfeld 3/30 Ruby on Rails: An introduction – What is Ruby on Rails? RoR: What is Ruby on Rails? •Full stack web application framework •Written in the Ruby programming language •Growing community since 2004 •Open Source and Free •Focused on developer productivity and getting the job done – fast! Maciej Mensfeld 4/30 Ruby on Rails: An introduction – What is Ruby on Rails? RoR: Why Ruby on Rails? Lot of frameworks exists on the market and a lot of programming languages for the web but… Rails leads Maciej Mensfeld 5/30 Ruby on Rails: An introduction – What is Ruby on Rails? RoR: Why Ruby on Rails? •Rails give the developers a real productivity boost for developing web applications •Because of Ruby and domain specific languages •Convention over Configuration •Productivity boost! 3-4 times faster than dev with zend Really faster? Maciej Mensfeld 6/30 Ruby on Rails: An introduction – What is Ruby on Rails? RoR: Why Ruby on Rails? Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller Also based on DRY concept Don’t Repeat Yourself (DRY) Every piece of knowledge should be expressed in just one place Maciej Mensfeld 7/30 Ruby on Rails: An introduction – Who uses RoR? I do! ;) (but not only…) and thousands of other… Maciej Mensfeld 8/30 Ruby on Rails: An introduction – The framework Lil bit bout Rails structure The Framework Maciej Mensfeld 9/30 Ruby on Rails: An introduction – The framework Lil bit bout Rails structure Try it out! cd ~ rails new my_blog … (output): create create README create Rakefile create config.ru create .gitignore create Gemfile create app create app/assets/images/rails.png … To much stuff! WTF?! Maciej Mensfeld 10/30 Ruby on Rails: An introduction – The framework Lil bit bout Rails structure Fortunately you don’t need to care about this :) Maciej Mensfeld 0 Ruby on Rails: An introduction – The framework MVC Maciej Mensfeld 12/30 Ruby on Rails: An introduction – The framework Rails MVC Maciej Mensfeld 13/30 Ruby on Rails: An introduction – The framework Models ;) Maciej Mensfeld 14/30 Ruby on Rails: An introduction – The framework ActiveRecord models Maciej Mensfeld 15/30 Ruby on Rails: An introduction – The framework Fat models, thin controllers Models should be… Maciej Mensfeld Fat! Fat! Fat!!!! Fat! Fat! Fat!!!! Fat! Fat! Fat!!!! Fat! Fat! Fat!!!! Fat! Fat! Fat!!!! 16/30 Ruby on Rails: An introduction – The framework But… don’t piss off Vegeta ;) Make fat models and thin controllers or Vegeta will visit U… Maciej Mensfeld 17/30 Ruby on Rails: An introduction – The framework ActionController Maciej Mensfeld 18/30 Ruby on Rails: An introduction – The framework ActionController – be Restful Maciej Mensfeld 19/30 Ruby on Rails: An introduction – The framework ActionController – be Restful Maciej Mensfeld 20/30 Ruby on Rails: An introduction – The framework ActionView Maciej Mensfeld 21/30 Ruby on Rails: An introduction – The framework ActionView templates ERB – templates with HTM and Ruby code – used to display dinamic stuff from prepared by controllers Maciej Mensfeld 22/30 Ruby on Rails: An introduction – Example app Enough theory, let’s start the magic! Maciej Mensfeld 23/30 Ruby on Rails: An introduction – Example app Generate Rails scaffold… Try it out! Maciej Mensfeld 24/30 Ruby on Rails: An introduction – Example app Start rails server to check if it works Try it out! Go to http://localhost:3000/ Maciej Mensfeld 25/30 Ruby on Rails: An introduction – Example app Yay! It works! Maciej Mensfeld 26/30 Ruby on Rails: An introduction – Example app Creating Posts Try it out! Maciej Mensfeld 27/30 Ruby on Rails: An introduction – Example app Creating Posts Try it out! Yeah it works but… we can create empty posts :( not good :( Maciej Mensfeld 28/30 Ruby on Rails: An introduction – Example app Protect create/update/destroy Try it out! Maciej Mensfeld Our blog works but anyone can add, edit and remove posts… shitty :/ 29/30 Ruby: writing some cool stuff Live long and prosper! Presented by: Maciej Mensfeld [email protected] dev.mensfeld.pl github.com/mensfeld Maciej Mensfeld 30/30
© Copyright 2024