Introduction to Ruby on Rails
Upcoming SlideShare
Loading in...5
×
 

Introduction to Ruby on Rails

on

  • 978 views

This presentation is done using Beamer. Source: https://github.com/vysakh0/beamer

This presentation is done using Beamer. Source: https://github.com/vysakh0/beamer

Statistics

Views

Total Views
978
Views on SlideShare
968
Embed Views
10

Actions

Likes
1
Downloads
25
Comments
0

1 Embed 10

https://twitter.com 10

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introduction to Ruby on Rails Introduction to Ruby on Rails Presentation Transcript

    • Web Development using Ruby on Rails Vysakh Sreenivasan Submify.com vysakh.quora.com vysakh0 - twitter/facebook March 24, 2013
    • Introduction to RubyTable of Contents 1 Introduction to Ruby Why Ruby? Features Getting Started Installation 2 Introduction to Rails Why Rails? MVC Pattern Ruby utilities Installation REST 3 Notes Installation Tutorials HelpVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 2 / 34
    • Introduction to RubyVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 3 / 34
    • Introduction to Ruby Why Ruby?Why Ruby? enjoy programmingVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 4 / 34
    • Introduction to Ruby Why Ruby?Why Ruby? be productive enjoy programmingVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 4 / 34
    • Introduction to Ruby Why Ruby?Why Ruby? be productive enjoy programming be happyVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 4 / 34
    • Introduction to Ruby FeaturesHELLO WORLD #include<stdio.h> int main(){ printf( ‘‘ Hello World ’’ ); return 0; }Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 5 / 34
    • Introduction to Ruby FeaturesHELLO WORLD import java.io.*; public class Example { public static void main(String[] args) { System.out.println( ‘‘ Hello World ’’ ); } }Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 6 / 34
    • Introduction to Ruby FeaturesSimplicity Ruby puts ‘‘Hello World’’Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 7 / 34
    • Introduction to Ruby FeaturesSimplicity Ruby puts ‘‘Hello World’’Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 7 / 34
    • Introduction to Ruby Features Easy to Learn Open Source Rich libraries Truly Object Oriented Less Coding with fewer bugs Helpful CommunityVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
    • Introduction to Ruby Features Easy to Learn Open Source Rich libraries Truly Object Oriented Less Coding with fewer bugs Helpful CommunityVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
    • Introduction to Ruby Features Easy to Learn Open Source Rich libraries Truly Object Oriented Less Coding with fewer bugs Helpful CommunityVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
    • Introduction to Ruby Features Easy to Learn Open Source Rich libraries Truly Object Oriented Less Coding with fewer bugs Helpful CommunityVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
    • Introduction to Ruby Features Easy to Learn Open Source Rich libraries Truly Object Oriented Less Coding with fewer bugs Helpful CommunityVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
    • Introduction to Ruby Features Easy to Learn Open Source Rich libraries Truly Object Oriented Less Coding with fewer bugs Helpful CommunityVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
    • Introduction to Ruby Getting Started Interactive Ruby Simple Syntax Variables Naming Convention ConstantsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
    • Introduction to Ruby Getting Started Type small bits of ruby code, see it get executed Interactive Ruby Simple Syntax Variables Naming Convention ConstantsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
    • Introduction to Ruby Getting Started Parenthesis, Braces, Tab spaces- Optional Interactive Ruby Simple Syntax Variables Naming Convention ConstantsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
    • Introduction to Ruby Getting Started a = 5 b = 10 Interactive Ruby c = a + b d = 11.4 Simple Syntax word = ‘‘Cool :)’’ Variables Naming Convention ConstantsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
    • Introduction to Ruby Getting Started Camel Case firstName = “vysakh” Interactive Ruby first_name=‘‘Vysakh’’ Simple Syntax Variables Naming Convention ConstantsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
    • Introduction to Ruby Getting Started Pi = 3.14 Interactive Ruby #Constants begin with Capital Simple Syntax Variables Naming Convention ConstantsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
    • Introduction to Ruby Getting Started In Ruby, everything isVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 10 / 34
    • Introduction to Ruby Getting Started if 1 == 1 puts ‘‘1 is equal to 1’’ elsif 1 != 1 Logical Operators puts ‘‘1 is not equal to 1’’ Loops else List puts ’’Something else‘‘ Hash and Sybmols end Functions ClassesVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
    • Introduction to Ruby Getting Started for while times upto Logical Operators downto Loops step List until Hash and Sybmols Functions ClassesVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
    • Introduction to Ruby Getting Started numbers = [1, 3, 55, 2999] fruits = [’’Mango‘‘, ’’Apple‘‘] Logical Operators mixed = [1, ’’Mango‘‘] Loops List Hash and Sybmols Functions ClassesVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
    • Introduction to Ruby Getting Started names = {’’first‘‘ => ’’Mark‘‘} #Strings are expensive Logical Operators # ‘‘first’’ is a string Loops # :first is a symbol List names = {:first => ’’Mark‘‘} Hash and Sybmols Functions ClassesVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
    • Introduction to Ruby Getting Started def add a, b a+b end Logical Operators puts add 1, 2 Loops List Hash and Sybmols Functions ClassesVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
    • Introduction to Ruby Getting Started class Calc def add a, b a+b Logical Operators end Loops end List Hash and Sybmols class ChildCalc < Calc Functions end Classes c = Calc.new puts c.add 4, 5 child = ChildCalc.new puts child.add 3, 4Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
    • Introduction to Ruby InstallationInstallation Use Ruby Version Management ToolVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 12 / 34
    • Introduction to Ruby InstallationInstallation Use Ruby Version Management Tool RVM or rbenvVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 12 / 34
    • Introduction to RailsTable of Contents 1 Introduction to Ruby Why Ruby? Features Getting Started Installation 2 Introduction to Rails Why Rails? MVC Pattern Ruby utilities Installation REST 3 Notes Installation Tutorials HelpVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 13 / 34
    • Introduction to RailsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 14 / 34
    • Introduction to Rails Why Rails?Why Rails? Extremely Productive Web Framework Develop 10 times faster than a Java Framework Rails promotes best practises Rails is very mature web framework Open Source, Vibrant Community Access to hundreds of gemsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
    • Introduction to Rails Why Rails?Why Rails? Extremely Productive Web Framework Develop 10 times faster than a Java Framework Rails promotes best practises Rails is very mature web framework Open Source, Vibrant Community Access to hundreds of gemsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
    • Introduction to Rails Why Rails?Why Rails? Extremely Productive Web Framework Develop 10 times faster than a Java Framework Rails promotes best practises Rails is very mature web framework Open Source, Vibrant Community Access to hundreds of gemsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
    • Introduction to Rails Why Rails?Why Rails? Extremely Productive Web Framework Develop 10 times faster than a Java Framework Rails promotes best practises Rails is very mature web framework Open Source, Vibrant Community Access to hundreds of gemsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
    • Introduction to Rails Why Rails?Why Rails? Extremely Productive Web Framework Develop 10 times faster than a Java Framework Rails promotes best practises Rails is very mature web framework Open Source, Vibrant Community Access to hundreds of gemsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
    • Introduction to Rails Why Rails?Why Rails? Extremely Productive Web Framework Develop 10 times faster than a Java Framework Rails promotes best practises Rails is very mature web framework Open Source, Vibrant Community Access to hundreds of gemsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
    • Introduction to Rails Why Rails?Rails Philosophy Convention over Configuration Donot Repeat Yourself (DRY) REST is the best pattern for web applicationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 16 / 34
    • Introduction to Rails Why Rails?Rails Philosophy Convention over Configuration Donot Repeat Yourself (DRY) REST is the best pattern for web applicationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 16 / 34
    • Introduction to Rails Why Rails?Rails Philosophy Convention over Configuration Donot Repeat Yourself (DRY) REST is the best pattern for web applicationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 16 / 34
    • Introduction to Rails Why Rails?FULL STACK FRAMEWORK.. WHAT?? It abstracts and manages all parts of a web application Database(model) HTML/visualization(view) Request flow(Controller)Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 17 / 34
    • Introduction to Rails Why Rails?FULL STACK FRAMEWORK.. WHAT?? It abstracts and manages all parts of a web application Database(model) HTML/visualization(view) Request flow(Controller)Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 17 / 34
    • Introduction to Rails Why Rails?FULL STACK FRAMEWORK.. WHAT?? It abstracts and manages all parts of a web application Database(model) HTML/visualization(view) Request flow(Controller)Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 17 / 34
    • Introduction to Rails MVC PatternMVC PatternVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 18 / 34
    • Introduction to Rails MVC PatternModel Maps a table in the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
    • Introduction to Rails MVC PatternModel Maps a table in the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
    • Introduction to Rails MVC PatternModel Maps a table in the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
    • Introduction to Rails MVC PatternModel Maps a table in the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associationsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
    • Introduction to Rails MVC PatternController Each method is a function that your application exposes Controls the flow of the request Exposes your data to viewsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 20 / 34
    • Introduction to Rails MVC PatternController Each method is a function that your application exposes Controls the flow of the request Exposes your data to viewsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 20 / 34
    • Introduction to Rails MVC PatternController Each method is a function that your application exposes Controls the flow of the request Exposes your data to viewsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 20 / 34
    • Introduction to Rails MVC PatternViews Show data to the user (in various format: html, csv, pdf..)Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 21 / 34
    • Introduction to Rails MVC PatternRoutes It is a map between the HTTP request and the method of a controllerVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 22 / 34
    • Introduction to Rails MVC PatternMigration add column/remove column rename column/rename table change column create table/drop tableVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 23 / 34
    • Introduction to Rails Ruby utilitiesRake Rake a simple ruby build program with capabilities similar to make. Create a file Rakefile namespace :my do task :alarm do puts ‘‘Turned off alarm.’’ end end Run this rake file with the command rake my:alarmVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 24 / 34
    • Introduction to Rails Ruby utilitiesgem and bundler gem A RubyGem is a software package, commonly called a gem. Gems contain a packaged Ruby application or library. bundler Bundler is the way to manage gem dependencies in RailsVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 25 / 34
    • Introduction to Rails InstallationInstallation and Creation Installing gem install rails Creation rails new projectVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 26 / 34
    • Introduction to Rails RESTWhat is REST?Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 27 / 34
    • Introduction to Rails RESTRepresentational State transfer REST in terms of Rails boils down to two main principles: Using resource identifiers such as URLs to represent resources. Transferring representations of the state of that resource between system components.Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 28 / 34
    • Introduction to Rails RESTRest - Example For example, the following HTTP request: DELETE /photos/17 would be understood to refer to a photo resource with the ID of 17, and to indicate a desired action: deleting that resource. In config/routes file resources :photos In controller class PhotosController < ApplicationController def destroy end endVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 29 / 34
    • NotesTable of Contents 1 Introduction to Ruby Why Ruby? Features Getting Started Installation 2 Introduction to Rails Why Rails? MVC Pattern Ruby utilities Installation REST 3 Notes Installation Tutorials HelpVysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 30 / 34
    • Notes InstallationInstallation rbenv https://github.com/sstephenson/rbenv RVM http://beginrescueend.com/ Windows http://railsinstaller.org/ Mac http://mxcl.github.com/homebrew/Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 31 / 34
    • Notes TutorialsTutorials Ruby http://tryruby.org/ Rails Getting Started with Rails http: //guides.rubyonrails.org/getting_started.html Michael Hartl’s Book http: //guides.rubyonrails.org/getting_started.html Rails Zombies http://railsforzombies.com/ Rails Reference Railscasts http://railscasts.com/Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 32 / 34
    • Notes HelpHelp Mailing list http://groups.google.com/group/rubyonrails-talk StackOverflow http://stackoverflow.com/Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 33 / 34
    • Notes HelpStart Coding! :)Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 34 / 34