SlideShare a Scribd company logo
1 of 43
Presentation to
Siltek Software Solutions (I) Pvt. Ltd.
Why does RoR interest us?
 Learn “new” concepts and terms.
 Look at “new” architecture.
 Find out what is good and what is dubious.
 May well come across RoR or a Rails-like framework in near
future.
 May want to learn an object-oriented language relatively
painlessly.
 RoR is easy to install, learn and use. You might want to try
it out for yourself!
Creator of Ruby
 Creator of Ruby
 Yukihiro Matsumoto aka Matz
 Birthday: 24 February 1993
 Originated in Japan and Rapidly
Gaining Mindshare in US and Europe.
Presentation Agenda
 Brief overview of Ruby
 Rails Demonstration
 Description of Rails framework
 Questions and Answers
Why Ruby?
 Write more understandable code in less lines
 Free (Very open license)
 Extensible
What is Ruby?
Dynamic, high level, interpreted, pure object-orientated
language.
“Ruby is designed to make programmers happy”
Yukihiro Matsumoto aka Matz
What is Ruby?
 Ruby is a pure object-oriented programming language with a super
clean syntax that makes programming elegant and fun.
 In Ruby, everything is an object
 Ruby is an interpreted scripting language, just like Perl, Python and
PHP.
 Ruby successfully combines Smalltalk's conceptual elegance, Python's
ease of use and learning and Perl's pragmatism.
 Ruby is a metaprogramming language. Metaprogramming is a means
of writing software programs that write or manipulate other programs
thereby making coding faster and more reliable.
Ruby is Truly Object-Oriented
 All classes derived from Object including Class (like Java)
but there are no primitives (not like Java at all)
 Ruby uses single-inheritance
 Mixins give you the power of multiple inheritance
without the headaches
 Modules allow addition of behaviors to a class
 Reflection is built in along with lots of other highly
dynamic metadata features
 Things like ‘=‘ and ‘+’ that you might think are operators
are actually methods (like Smalltalk)
Dynamic Programming
 Duck Typing
Based on signatures, not class inheritance
 Dynamic Dispatch
A key concept of OOP: methods are actually messages that are
sent to an object instance
 Dynamic Behavior
 Reflection
 Scope Reopening (Kind of like AOP)
 Eval
 Breakpoint debugger
What about Ruby on Rails?
Terms and Concepts
 MVC (Model-View-Controller)
 Duck Typing
 DRY (Don’t Repeat Yourself)
 Convention Over Configuration
 Scaffolding
 Migrations
 Validations
 Associations
 Mailers
Directory Layout
Rails applications have a common directory structure
/app - the MVC core
/controllers
/helpers - provides extra functionality for views
/models
/views/nameofcontroller - templates for controller
actions
Directory Layout
/components - will be deprecated
/config - database, route and environment configuration
/db - database schema and migrations
/lib - functions that don’t map to MVC
/log
/public - static web resources (html, css, javascript etc.)
/script - rails utilities
/test - tests and fixtures
/tmp
/vendor - 3rd party plugins
Rails Directory Structure
MVC Architecture
The Obligatory Architecture Slide
Model – View – Controller
• Separate data (model) from user interface (view)
 Model
 data access and business logic
 independent of the view and controller
 View
 data presentation and user interaction
 read-only access to the model
 Controller
 handling events
 operating on model and view
Model – Active Record
 Object Relational Mapping
 “ActiveRecord”
 Less Database “glue” Code
 Logging for Performance Checking
Model : Rules
 Table Names
 Plurals
 Attribute Names
 id for primary key in table
 table_id for foreign key in other table
View – Action View
 multiple template types
 oldest and basic: erb (embedded ruby), similar to e.g. jsp
 remote javascript templates
 xml templates
 easy reuse of view elements
 file inclusion – layouts, templates, partials
 multiple standard "helpers" – common html element
generators (e.g. form elements, paginators)
 easy AJAX integration
Controller : ActionController
 Method name matches view folder
 users_controller.rb works for /views/users/***.rhtml
 called “actions”
 all view’s methods will sit there
 Ability to
 CRUD
 Flash
 Redirect
Database Persistence
 OR mapping
 Active Record design pattern
 migrations
 incremental schema management
 multiple db adapters
 MySQL, PostgreSQL, SQLite, SQL Server, IBM DB2,
Informix, Oracle
Duck Typing in Ruby
 Objects are dynamic, and their types are determined at
runtime
 The type of a Ruby object is much less important than it’s
capabilities
 If a Ruby object walks like a duck and talks like a duck,
then it can be treated as a duck
Convention over Configuration
 fixed directory structure
 everything has its place – source
files, libs, plugins, database files, documentation etc
 file naming conventions
 e.g. camel case class name, underscore file name
 database naming conventions
 table names, primary and foreign keys
 standard configuration files
 e.g. database connections, environment setting
definitions (development, production, test)
DRY - Don’t Repeat Yourself
 reusing code
 e.g. view elements
 reusing data
 e.g. no need to declare table field names – can be read
from the database
 making each line of code work harder
 e.g. mini languages for specific domains
 object-relational mapping
 metaprogramming
 dynamically created methods
Rails Environment Modes
 Rails runs in different modes, depending on the parameters
given to the server on startup. Each mode defaults to it’s
own database schema
Development (verbose logging and error messages)
Test
Production
Web Servers
 Lighttpd
 Mongrel
 WEBrick
 Apache
RoR Databases
 Mysql
 Oracle
 Postgre Sql
 SqlLite
Scaffolding
 Rails can generate all the basic CRUD operations
for simple models via scaffolding.
 Scaffolding is temporary way to get applications
wired quickly.
 ruby script/generate scaffold_resource
bookmark url:string title:string
Migrations
 Rails uses migrations to version the database.
 Rails tries to minimize SQL at every opportunity
 Migrations are automatically created whenever you
generate a new model
 Migration files are located in db/migrations
 The version number is stored in a table called
schema_info
Running the Migration
 Rake is the general purpose build tool for
rails, much like make, or ant. It has many
functions, one of which is to control migrations.
 rake db:migrate
 Now the table has been created
Validations
 Rails has a number of validation helpers that can
be added to the model.
class Bookmark < ActiveRecord::Base
validates_presence_of :url, :title
end
Validations
 validates_presence_of
 validates_length_of
 validates_acceptance_of
 validates_confirmation_of
 validates_uniqueness_of
 validates_format_of
 validates_numericality_of
 validates_inclusion_in
 validates_exclusion_of
 validates_associated :relation
Associations
 Rails uses associations to build relationships
between tables
 Associations are independent of database foreign
key constraints
Types of Associations
 has_one
 belongs_to
 has_many
 has_and_belongs_to_many
 has_many :model1, :through => :model2
Mailers
 Action Mailer allows you to send emails from your
application using a mailer model and views. So, in
Rails, emails are used by creating models that
inherit from ActionMailer::Base that live alongside
other models in app/models. Those models have
associated views that appear alongside controller
views in app/views.
Rake
 Ruby’s Build System
 Familiar to Ant users
 Your build file is a written in Ruby
 Basic build script provided with Rails project
Recommended Rails reading
 Simply Rails 2.0
 Sitepoint.com
Great for
beginners
 Agile Web Development with Rails
 PragProg.com
A little bit
more advanced
Resources
 Ruby on Rails: Talk (Google Group)
 http://groups.google.com/group/rubyonrails-talk
 Railscasts (free Ruby on Rails screencasts)
 http://railscasts.com
 Peep Code (paid Rails-related screencasts)
 http://peepcode.com
 Phusion Passenger (easy deployment module)
 http://www.modrails.com
 Agile Web Development (plugin central)
 http://agilewebdevelopment.com/
Who uses Ruby on Rails?
References
 www.slideshare.net
 www.youtube.com
 www.google.com
 http://www.netbeans.org/kb/docs/ruby/rapid-ruby-
weblog.html
 http://guides.rails.info/getting_started.html
 www.rubyonrails.org
 http://www.tutorialspoint.com/ruby-on-rails-2.1
Ruby on rails for beginers
Ruby on rails for beginers

More Related Content

What's hot

(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep DiveAmazon Web Services
 
AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...
AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...
AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...Brian Andrzejewski
 
DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)
DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)
DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)AWSKRUG - AWS한국사용자모임
 
AWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and HistoryAWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and HistoryAmazon Web Services
 
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...Amazon Web Services Korea
 
Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...
Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...
Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...Amazon Web Services LATAM
 
Familiae Romanae Vocabula (IV)
Familiae Romanae Vocabula (IV)Familiae Romanae Vocabula (IV)
Familiae Romanae Vocabula (IV)Óscar Ramos
 
[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)
[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)
[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)NAVER CLOUD PLATFORMㅣ네이버 클라우드 플랫폼
 

What's hot (11)

(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive
 
AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...
AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...
AWS reInforce 2021: TDR202 - Lessons learned from the front lines of Incident...
 
DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)
DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)
DynamoDB의 안과밖 - 정민영 (비트패킹 컴퍼니)
 
Security on AWS
Security on AWSSecurity on AWS
Security on AWS
 
AWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and HistoryAWSome Day 2016 - Module 1: AWS Introduction and History
AWSome Day 2016 - Module 1: AWS Introduction and History
 
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
AWS Fault Injection Simulator를 통한 실전 카오스 엔지니어링 - 윤석찬 AWS 수석 테크에반젤리스트 / 김신 SW엔...
 
Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...
Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...
Migrando seu banco de dados para a AWS - Deep Dive em Amazon RDS e AWS Databa...
 
AWSome Day Dublin - June 2016
AWSome Day Dublin - June 2016AWSome Day Dublin - June 2016
AWSome Day Dublin - June 2016
 
Familiae Romanae Vocabula (IV)
Familiae Romanae Vocabula (IV)Familiae Romanae Vocabula (IV)
Familiae Romanae Vocabula (IV)
 
[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)
[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)
[온라인교육시리즈] 네이버 클라우드 플랫폼 init script 활용법 소개(정낙수 클라우드 솔루션 아키텍트)
 
Amazon GuardDuty Lab
Amazon GuardDuty LabAmazon GuardDuty Lab
Amazon GuardDuty Lab
 

Similar to Ruby on rails for beginers

Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web DevelopmentSonia Simi
 
Ruby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupRuby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupJose de Leon
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorialsunniboy
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction Tran Hung
 
Ruby on Rails: Building Web Applications Is Fun Again!
Ruby on Rails: Building Web Applications Is Fun Again!Ruby on Rails: Building Web Applications Is Fun Again!
Ruby on Rails: Building Web Applications Is Fun Again!judofyr
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to railsEvgeniy Hinyuk
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukPivorak MeetUp
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon RailsPaul Pajo
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Railsanides
 

Similar to Ruby on rails for beginers (20)

Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby on Rails
Ruby on Rails Ruby on Rails
Ruby on Rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Intro ror
Intro rorIntro ror
Intro ror
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Ruby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User GroupRuby On Rails - Rochester K Linux User Group
Ruby On Rails - Rochester K Linux User Group
 
Ruby on rails RAD
Ruby on rails RADRuby on rails RAD
Ruby on rails RAD
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction
 
Rails interview questions
Rails interview questionsRails interview questions
Rails interview questions
 
Ruby on Rails: Building Web Applications Is Fun Again!
Ruby on Rails: Building Web Applications Is Fun Again!Ruby on Rails: Building Web Applications Is Fun Again!
Ruby on Rails: Building Web Applications Is Fun Again!
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to rails
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy Hinyuk
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon Rails
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 

Recently uploaded

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Ruby on rails for beginers

  • 1. Presentation to Siltek Software Solutions (I) Pvt. Ltd.
  • 2. Why does RoR interest us?  Learn “new” concepts and terms.  Look at “new” architecture.  Find out what is good and what is dubious.  May well come across RoR or a Rails-like framework in near future.  May want to learn an object-oriented language relatively painlessly.  RoR is easy to install, learn and use. You might want to try it out for yourself!
  • 3. Creator of Ruby  Creator of Ruby  Yukihiro Matsumoto aka Matz  Birthday: 24 February 1993  Originated in Japan and Rapidly Gaining Mindshare in US and Europe.
  • 4. Presentation Agenda  Brief overview of Ruby  Rails Demonstration  Description of Rails framework  Questions and Answers
  • 5. Why Ruby?  Write more understandable code in less lines  Free (Very open license)  Extensible
  • 6. What is Ruby? Dynamic, high level, interpreted, pure object-orientated language. “Ruby is designed to make programmers happy” Yukihiro Matsumoto aka Matz
  • 7. What is Ruby?  Ruby is a pure object-oriented programming language with a super clean syntax that makes programming elegant and fun.  In Ruby, everything is an object  Ruby is an interpreted scripting language, just like Perl, Python and PHP.  Ruby successfully combines Smalltalk's conceptual elegance, Python's ease of use and learning and Perl's pragmatism.  Ruby is a metaprogramming language. Metaprogramming is a means of writing software programs that write or manipulate other programs thereby making coding faster and more reliable.
  • 8. Ruby is Truly Object-Oriented  All classes derived from Object including Class (like Java) but there are no primitives (not like Java at all)  Ruby uses single-inheritance  Mixins give you the power of multiple inheritance without the headaches  Modules allow addition of behaviors to a class  Reflection is built in along with lots of other highly dynamic metadata features  Things like ‘=‘ and ‘+’ that you might think are operators are actually methods (like Smalltalk)
  • 9. Dynamic Programming  Duck Typing Based on signatures, not class inheritance  Dynamic Dispatch A key concept of OOP: methods are actually messages that are sent to an object instance  Dynamic Behavior  Reflection  Scope Reopening (Kind of like AOP)  Eval  Breakpoint debugger
  • 10. What about Ruby on Rails?
  • 11. Terms and Concepts  MVC (Model-View-Controller)  Duck Typing  DRY (Don’t Repeat Yourself)  Convention Over Configuration  Scaffolding  Migrations  Validations  Associations  Mailers
  • 12. Directory Layout Rails applications have a common directory structure /app - the MVC core /controllers /helpers - provides extra functionality for views /models /views/nameofcontroller - templates for controller actions
  • 13. Directory Layout /components - will be deprecated /config - database, route and environment configuration /db - database schema and migrations /lib - functions that don’t map to MVC /log /public - static web resources (html, css, javascript etc.) /script - rails utilities /test - tests and fixtures /tmp /vendor - 3rd party plugins
  • 17. Model – View – Controller • Separate data (model) from user interface (view)  Model  data access and business logic  independent of the view and controller  View  data presentation and user interaction  read-only access to the model  Controller  handling events  operating on model and view
  • 18. Model – Active Record  Object Relational Mapping  “ActiveRecord”  Less Database “glue” Code  Logging for Performance Checking
  • 19. Model : Rules  Table Names  Plurals  Attribute Names  id for primary key in table  table_id for foreign key in other table
  • 20. View – Action View  multiple template types  oldest and basic: erb (embedded ruby), similar to e.g. jsp  remote javascript templates  xml templates  easy reuse of view elements  file inclusion – layouts, templates, partials  multiple standard "helpers" – common html element generators (e.g. form elements, paginators)  easy AJAX integration
  • 21. Controller : ActionController  Method name matches view folder  users_controller.rb works for /views/users/***.rhtml  called “actions”  all view’s methods will sit there  Ability to  CRUD  Flash  Redirect
  • 22. Database Persistence  OR mapping  Active Record design pattern  migrations  incremental schema management  multiple db adapters  MySQL, PostgreSQL, SQLite, SQL Server, IBM DB2, Informix, Oracle
  • 23. Duck Typing in Ruby  Objects are dynamic, and their types are determined at runtime  The type of a Ruby object is much less important than it’s capabilities  If a Ruby object walks like a duck and talks like a duck, then it can be treated as a duck
  • 24. Convention over Configuration  fixed directory structure  everything has its place – source files, libs, plugins, database files, documentation etc  file naming conventions  e.g. camel case class name, underscore file name  database naming conventions  table names, primary and foreign keys  standard configuration files  e.g. database connections, environment setting definitions (development, production, test)
  • 25. DRY - Don’t Repeat Yourself  reusing code  e.g. view elements  reusing data  e.g. no need to declare table field names – can be read from the database  making each line of code work harder  e.g. mini languages for specific domains  object-relational mapping  metaprogramming  dynamically created methods
  • 26. Rails Environment Modes  Rails runs in different modes, depending on the parameters given to the server on startup. Each mode defaults to it’s own database schema Development (verbose logging and error messages) Test Production
  • 27. Web Servers  Lighttpd  Mongrel  WEBrick  Apache
  • 28. RoR Databases  Mysql  Oracle  Postgre Sql  SqlLite
  • 29. Scaffolding  Rails can generate all the basic CRUD operations for simple models via scaffolding.  Scaffolding is temporary way to get applications wired quickly.  ruby script/generate scaffold_resource bookmark url:string title:string
  • 30. Migrations  Rails uses migrations to version the database.  Rails tries to minimize SQL at every opportunity  Migrations are automatically created whenever you generate a new model  Migration files are located in db/migrations  The version number is stored in a table called schema_info
  • 31. Running the Migration  Rake is the general purpose build tool for rails, much like make, or ant. It has many functions, one of which is to control migrations.  rake db:migrate  Now the table has been created
  • 32. Validations  Rails has a number of validation helpers that can be added to the model. class Bookmark < ActiveRecord::Base validates_presence_of :url, :title end
  • 33. Validations  validates_presence_of  validates_length_of  validates_acceptance_of  validates_confirmation_of  validates_uniqueness_of  validates_format_of  validates_numericality_of  validates_inclusion_in  validates_exclusion_of  validates_associated :relation
  • 34. Associations  Rails uses associations to build relationships between tables  Associations are independent of database foreign key constraints
  • 35. Types of Associations  has_one  belongs_to  has_many  has_and_belongs_to_many  has_many :model1, :through => :model2
  • 36. Mailers  Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating models that inherit from ActionMailer::Base that live alongside other models in app/models. Those models have associated views that appear alongside controller views in app/views.
  • 37. Rake  Ruby’s Build System  Familiar to Ant users  Your build file is a written in Ruby  Basic build script provided with Rails project
  • 38. Recommended Rails reading  Simply Rails 2.0  Sitepoint.com Great for beginners  Agile Web Development with Rails  PragProg.com A little bit more advanced
  • 39. Resources  Ruby on Rails: Talk (Google Group)  http://groups.google.com/group/rubyonrails-talk  Railscasts (free Ruby on Rails screencasts)  http://railscasts.com  Peep Code (paid Rails-related screencasts)  http://peepcode.com  Phusion Passenger (easy deployment module)  http://www.modrails.com  Agile Web Development (plugin central)  http://agilewebdevelopment.com/
  • 40. Who uses Ruby on Rails?
  • 41. References  www.slideshare.net  www.youtube.com  www.google.com  http://www.netbeans.org/kb/docs/ruby/rapid-ruby- weblog.html  http://guides.rails.info/getting_started.html  www.rubyonrails.org  http://www.tutorialspoint.com/ruby-on-rails-2.1