Why Ruby? Features Getting Started Installation 2 Introduction to Rails Why Rails? MVC Pattern Ruby utilities Installation REST 3 Notes Installation Tutorials Help Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 2 / 34
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
libraries Truly Object Oriented Less Coding with fewer bugs Helpful Community Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
libraries Truly Object Oriented Less Coding with fewer bugs Helpful Community Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
libraries Truly Object Oriented Less Coding with fewer bugs Helpful Community Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
libraries Truly Object Oriented Less Coding with fewer bugs Helpful Community Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
libraries Truly Object Oriented Less Coding with fewer bugs Helpful Community Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
libraries Truly Object Oriented Less Coding with fewer bugs Helpful Community Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 8 / 34
Naming Convention Constants Type small bits of ruby code, see it get executed Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
Naming Convention Constants Parenthesis, Braces, Tab spaces- Optional Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
Naming Convention Constants a = 5 b = 10 c = a + b d = 11.4 word = ‘‘Cool :)’’ Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
Naming Convention Constants Camel Case firstName = “vysakh” first_name=‘‘Vysakh’’ Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
Naming Convention Constants Pi = 3.14 #Constants begin with Capital Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 9 / 34
and Sybmols Functions Classes if 1 == 1 puts ‘‘1 is equal to 1’’ elsif 1 != 1 puts ‘‘1 is not equal to 1’’ else puts ’’Something else‘‘ end Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
and Sybmols Functions Classes for while times upto downto step until Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
and Sybmols Functions Classes names = {’’first‘‘ => ’’Mark‘‘} #Strings are expensive # ‘‘first’’ is a string # :first is a symbol names = {:first => ’’Mark‘‘} Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
and Sybmols Functions Classes def add a, b a+b end puts add 1, 2 Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
and Sybmols Functions Classes class Calc def add a, b a+b end end class ChildCalc < Calc end c = Calc.new puts c.add 4, 5 child = ChildCalc.new puts child.add 3, 4 Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 11 / 34
Why Ruby? Features Getting Started Installation 2 Introduction to Rails Why Rails? MVC Pattern Ruby utilities Installation REST 3 Notes Installation Tutorials Help Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 13 / 34
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 gems Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
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 gems Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
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 gems Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
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 gems Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
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 gems Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
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 gems Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 15 / 34
Donot Repeat Yourself (DRY) REST is the best pattern for web applications Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 16 / 34
Donot Repeat Yourself (DRY) REST is the best pattern for web applications Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 16 / 34
Donot Repeat Yourself (DRY) REST is the best pattern for web applications Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 16 / 34
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
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
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
the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associations Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associations Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associations Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
the database with a ruby object Validates your data before saving them Here you manipulate your data Here you add associations Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 19 / 34
function that your application exposes Controls the flow of the request Exposes your data to views Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 20 / 34
function that your application exposes Controls the flow of the request Exposes your data to views Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 20 / 34
function that your application exposes Controls the flow of the request Exposes your data to views Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 20 / 34
between the HTTP request and the method of a controller Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 22 / 34
column/rename table change column create table/drop table Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 23 / 34
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:alarm Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 24 / 34
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 Rails Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 25 / 34
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
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 end Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 29 / 34
Features Getting Started Installation 2 Introduction to Rails Why Rails? MVC Pattern Ruby utilities Installation REST 3 Notes Installation Tutorials Help Vysakh Sreenivasan (vysakh.quora.com) Web Development using Ruby on Rails March 24, 2013 30 / 34
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