SlideShare a Scribd company logo
Ruby on Rails
Mehmet Beydogan
2014
Ruby on Rails
Mehmet Beydogan
2014
Why Ruby?
“Ruby is natural more than simple”
Everything is an object
5.times do
puts “Hello World”
end
Hello World
Hello World
Hello World
Hello World
Hello World
5.class
=> Fixnum=> Fixnum
nil.class
=> NilClass
Ruby Blocks
patients.each do |patient|
if patient.ill?
physician.examine patient
else
patient.jump_for_joy!
end
end
You can group a set of instructions together
Open Classes
class String
def write_size
self.size
end
end
size_writer = "Tell me my size!"
puts size_writer.write_size
In Ruby, classes are never closed,
you can always add methods to an existing class.
Method Missing
class Dummy
def method_missing(m, *args, &block)
puts "There's no method #{m}"
end
end
Dummy.new.anything
method_missing is in part a safety net: It gives you a way to
intercept unanswerable messages and handle them gracefully
Method Missing
User.find_by_name
User.find_by_email
You can use regular expressions to more dynamic classes
Ruby on Rails
Rails
-Convention Over Confuguration
-DRY – Dont Repeat Yourself
-MVC
Princibles
Convention Over
Confuguration
Model: User
Table: users
Controller: users_controller
MVC
REST
-simplifies component implementation
-reduces the complexity of connector semantics,
Rails Components
-Active Record
-Database Migrations
-Active Record Validations
-Active Record Callbacks
-Active Record Assocations
Model Layer
-Action View
-Layouts & Partials
-Rendering
View Layer
-Controller Overview
-Routing
Controller Layer
Rails Components
-i18n
-Action Mailer
-Asset Pipeline
-Generators
More Components
Model Layer
Active Record
-Represent models and their data
-Represent associations between these models
-Represent inheritance hierarchies through related models
-Validate models before they get persisted to the database
-Perform database operations in an object-oriented fashion.
Creating Active Record
Models
Read
Update
Delete
Active Record Migrations
app/db/migrations/create_publications.rb
Active Record Migrations
Supported Methods
add_column
add_index
add_reference
add_timestamps
create_table
create_join_table
drop_table
drop_join_table
remove_timestamps
rename_column
rename_index
remove_reference
rename_table
Running Migrations
Active Record Validations
Validations are used to ensure that only valid data is saved into your database.
format
length
numericality
presence
uniqueness
Validation Errors
Active Record Callbacks
-Active Record provides hooks into this object life cycle so
that you can control your application and its data.
-Callbacks allow you to trigger logic before or after an
alteration of an object's state.
Callback Registration
When does it get triggered?
-Creating an Object
before_validation
after_validation
before_save
around_save
before_create
around_create
after_create
after_save
-Updating an Object
before_validation
after_validation
before_save
around_save
before_update
around_update
after_update
after_save
-Destroying an Object
before_destroy
around_destroy
after_destroy
Active Record Associations
They make common operations simpler and easier in your code.
-Get a user's all posts
-Get the author of a post
Why Associations?
Consider we have Order and Customer models
Why Associations?
Creating an order
Why Associations?
Deleting all orders of a customer while deleting a customer
IT'S PAINFUL!
Use Associations
Creating an order
Deleting a customer with it's orders
belongs_to
has_one
has_many
has_and_belongs_to_many
has_many through
Polymorphic
View Layer
-Action View
-Layouts & Partials
-Rendering
Action View
-Action View is responsible for compiling the response.
-Action View templates are written using embedded Ruby in tags mingled with HTML.
-All view files must be in app/views folder
app/views/posts/index.html.erb
app/views/posts/new.html.erb
app/views/posts/edit.html.erb
app/views/posts/show.html.erb
Templates
ERB: Embedded RuBy
list_people.html.erb
Partials
To simplify templates
Controller Layer
-Controller Overview
-Routing
Controller Layer
-Controller is responsible for making sense of the request and producing the
appropriate output
-Rails favors pluralization of the last word in the controller's name
ClientsController
SiteAdminsController
PostsController
Ruby On Rails
Routing
-The Rails router recognizes URLs and dispatches them to a controller's action.
-Generate paths and URLs, avoiding the need to hardcode strings in your views.
routes.rb
Request
index.html.erb
Where to start?
-http://guides.rubyonrails.org
-http://railscasts.com
Questions?

More Related Content

Viewers also liked (18)

ODP
Eguberriak
armendariznaroa
 
ODP
Eguneroko ibilbidea
armendariznaroa
 
ODP
Impres anton
armendariznaroa
 
PPT
Coma final
ashabdou
 
PPTX
VPRS - Second seminar presentation
Ahmed Abd El-Fattah
 
PPT
Practica 7.powerpoint
Carolina Apellidos
 
DOCX
Survey 1 (project overview)
Ahmed Abd El-Fattah
 
PDF
VBPR 1st seminar
Ahmed Abd El-Fattah
 
PPTX
Bullying in schools.
xjessxgee
 
ODP
Eguneroko ibilbidea
armendariznaroa
 
PPTX
Vitale Skin-Green Skincare made with wheatgrass
Vitale Skin
 
PPT
什么是Ui
nanacn168
 
PPT
产品设计与用户体验(马化腾)
nanacn168
 
PPT
Myasthenia gravis
ashabdou
 
PPTX
Status epilepticus : TIME FOR NEW GUIDLINES
ashabdou
 
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
KEY
Enterprise Architectures with Ruby (and Rails)
Konstantin Gredeskoul
 
PPTX
AngularJS Architecture
Eyal Vardi
 
Eguberriak
armendariznaroa
 
Eguneroko ibilbidea
armendariznaroa
 
Impres anton
armendariznaroa
 
Coma final
ashabdou
 
VPRS - Second seminar presentation
Ahmed Abd El-Fattah
 
Practica 7.powerpoint
Carolina Apellidos
 
Survey 1 (project overview)
Ahmed Abd El-Fattah
 
VBPR 1st seminar
Ahmed Abd El-Fattah
 
Bullying in schools.
xjessxgee
 
Eguneroko ibilbidea
armendariznaroa
 
Vitale Skin-Green Skincare made with wheatgrass
Vitale Skin
 
什么是Ui
nanacn168
 
产品设计与用户体验(马化腾)
nanacn168
 
Myasthenia gravis
ashabdou
 
Status epilepticus : TIME FOR NEW GUIDLINES
ashabdou
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Enterprise Architectures with Ruby (and Rails)
Konstantin Gredeskoul
 
AngularJS Architecture
Eyal Vardi
 

Similar to Ruby On Rails (20)

PPT
Ruby on rails
chamomilla
 
PDF
Getting Started with Rails
Basayel Said
 
PDF
Ruby On Rails
Balint Erdi
 
PDF
مقایسه و بررسی چهارچوب ریلز
railsbootcamp
 
PPTX
12 Introduction to Rails
Deepak Hagadur Bheemaraju
 
PPT
Ruby On Rails
guest4faf46
 
PDF
Story for a Ruby on Rails Single Engineer
TylerJohnson988371
 
PDF
Intro to Ruby on Rails: From Zero to Basics
Oppo16
 
KEY
Supa fast Ruby + Rails
Jean-Baptiste Feldis
 
PPTX
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Kenneth Teh
 
PPT
Ruby On Rails
Gautam Rege
 
PPT
Ruby on Rails: Building Web Applications Is Fun Again!
judofyr
 
PDF
Lecture #5 Introduction to rails
Evgeniy Hinyuk
 
PDF
Introduction to Rails by Evgeniy Hinyuk
Pivorak MeetUp
 
PPT
Ruby On Rails Tutorial
sunniboy
 
PPTX
Intro to Rails and MVC
Sarah Allen
 
PDF
Introduction to Rails - presented by Arman Ortega
arman o
 
PDF
Ruby Rails Web Development
Sonia Simi
 
DOC
Rails interview questions
Durgesh Tripathi
 
PPT
Ruby On Rails Seminar Basis Softexpo Feb2010
arif44
 
Ruby on rails
chamomilla
 
Getting Started with Rails
Basayel Said
 
Ruby On Rails
Balint Erdi
 
مقایسه و بررسی چهارچوب ریلز
railsbootcamp
 
12 Introduction to Rails
Deepak Hagadur Bheemaraju
 
Ruby On Rails
guest4faf46
 
Story for a Ruby on Rails Single Engineer
TylerJohnson988371
 
Intro to Ruby on Rails: From Zero to Basics
Oppo16
 
Supa fast Ruby + Rails
Jean-Baptiste Feldis
 
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Kenneth Teh
 
Ruby On Rails
Gautam Rege
 
Ruby on Rails: Building Web Applications Is Fun Again!
judofyr
 
Lecture #5 Introduction to rails
Evgeniy Hinyuk
 
Introduction to Rails by Evgeniy Hinyuk
Pivorak MeetUp
 
Ruby On Rails Tutorial
sunniboy
 
Intro to Rails and MVC
Sarah Allen
 
Introduction to Rails - presented by Arman Ortega
arman o
 
Ruby Rails Web Development
Sonia Simi
 
Rails interview questions
Durgesh Tripathi
 
Ruby On Rails Seminar Basis Softexpo Feb2010
arif44
 
Ad

Recently uploaded (20)

PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
PPTX
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
Get Started with Maestro: Agent, Robot, and Human in Action – Session 5 of 5
klpathrudu
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
Ad

Ruby On Rails