SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
Everyday Rails
brought by Blaze Hadzik and
Blaze Hadzik
Ruby on Rails developer
blazej.hadzik@netguru.co
netguru
Software house
web&mobile
Team
Poznan, Warsaw, Gdansk, Krakow
Australia, India, America, Brazil
#transparency
Workshops
2 days
teams with mentors
fun
recruitment
/ˈruː.bi/
‘Programming languages must feel
natural to programmers.’
Matz
Ruby is a dynamic, scripting, object-
oriented language...
:014 > 1.class
=> Fixnum
:015 > (2.2).class
=> Float
:016 > [].class
=> Array
:017 > "Politechnika Slaska".class
=> String
:018 > nil.class
=> NilClass
:019 > “abc” + “d”
=> “abcd”
variables
type local instance class global constant
example name @name @@name $name NAME
you don’t have to specify variable type
Variables
a = 12
a.class # => Integer
a = “polsl”
a.class # => String
a = [‘a’, ‘b’, ‘c’]
a.class # => Array
Arrays and Hashes
a = [ 'ant', 'bee', 'cat', 'dog', 'elk' ]
a[0] # => "ant"
a[3] # => "dog"
# this is the same:
a = %w{ ant bee cat dog elk }
a[0] # => "ant"
a[3] # => "dog"
Arrays and Hashes
my_hash = {
building: ‘school’,
fruit: ‘orange’
}
puts my_hash[:building] # => ‘school’
Symbols
LOW_PRIORITY = 0
HIGH_PRIORITY = 1
priority = HIGH_PRIORITY
vs
priority = :high
Symbols are simply constants that you don’t have to predeclare and that are guaranteed to be unique.
Control structures
if/else statements
case statements
while structure
Blocks
Idioms
Idioms
a, b = 1, 2
a += b
a # => 3
@a ||= 1 # @a = 1 if @a.nil?
Classes, objects
Classes, objects
class School
def initialize(name)
@name = name
end
end
school = School.new(‘polsl’)
p school # =>#<School:0x007fa301836160 @name="polsl">
Class Attributes
class School
def initialize(name)
@name = name
end
def name=(name)
@name = name
end
def name
@name
end
end
Class Attributes
attr_reader
attr_writer
attr_accessor
Access Control
private
protected
public
Rails
‘It is impossible not to notice Ruby on Rails.’
Martin Fowler
Ruby is language
Rails is framework
DRY
Service Objects
Decorators
Convention over
Configuration
REST
Structure
controllers
models
views
routes.rb, database.yml
Gemfile
MVC
controller
model view
browser
DB
routes
web server
http://localhost:3000/
127.0.0.1 - GET /index.html HTTP/1.0" 200 2326
get ‘/’, to: ‘welcome#index’
class WelcomeController < ApplicationController
def index
@posts = Post.all
end
end
class Post < ActiveRecord::Base
end
class Post < ActiveRecord::Base
end
class WelcomeController < ApplicationController
def index
@posts = Post.all
end
end
<ul>
<% @posts.each do |post| %>
<li>
<%= post.title %>
</li>
<% end %>
</ul>
<html>
…
<body>
…
<%= yield %>
…
</body>
</html
http://localhost:3000/http://localhost:3000/
Let’s code
Thanks

Contenu connexe

En vedette

Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruRozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Biznes 2.0
 
Blogi w firmie
Blogi w firmieBlogi w firmie
Blogi w firmie
Netguru
 

En vedette (11)

Agile Retrospectives
Agile RetrospectivesAgile Retrospectives
Agile Retrospectives
 
KISS Augmented Reality
KISS Augmented RealityKISS Augmented Reality
KISS Augmented Reality
 
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
 
Defining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyDefining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using Ruby
 
Communication With Clients Throughout The Project
Communication With Clients Throughout The ProjectCommunication With Clients Throughout The Project
Communication With Clients Throughout The Project
 
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruRozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
 
From Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z PasjąFrom Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z Pasją
 
Blogi w firmie
Blogi w firmieBlogi w firmie
Blogi w firmie
 
Ruby Rails Overview
Ruby Rails OverviewRuby Rails Overview
Ruby Rails Overview
 
How To Build Great Relationships With Your Clients
How To Build Great Relationships With Your ClientsHow To Build Great Relationships With Your Clients
How To Build Great Relationships With Your Clients
 
Payments integration: Stripe & Taxamo
Payments integration: Stripe & TaxamoPayments integration: Stripe & Taxamo
Payments integration: Stripe & Taxamo
 

Similaire à Everyday Rails

Groovy Fly Through
Groovy Fly ThroughGroovy Fly Through
Groovy Fly Through
niklal
 
Raven lovin' - .NET does NoSQL
Raven lovin' - .NET does NoSQLRaven lovin' - .NET does NoSQL
Raven lovin' - .NET does NoSQL
Judah Himango
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»
e-Legion
 
Ruby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic IntroductionRuby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic Introduction
Prabu D
 

Similaire à Everyday Rails (20)

Groovy Fly Through
Groovy Fly ThroughGroovy Fly Through
Groovy Fly Through
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
Javascript Journey
Javascript JourneyJavascript Journey
Javascript Journey
 
Raven lovin' - .NET does NoSQL
Raven lovin' - .NET does NoSQLRaven lovin' - .NET does NoSQL
Raven lovin' - .NET does NoSQL
 
Intro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneIntro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG Cologne
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»
 
Rapid web development, the right way.
Rapid web development, the right way.Rapid web development, the right way.
Rapid web development, the right way.
 
Ruby on Rails For .Net Programmers
Ruby on Rails For .Net ProgrammersRuby on Rails For .Net Programmers
Ruby on Rails For .Net Programmers
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
 
iOS Development with RubyMotion
iOS Development with RubyMotioniOS Development with RubyMotion
iOS Development with RubyMotion
 
NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)
NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)
NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)
 
Ruby Programming
Ruby ProgrammingRuby Programming
Ruby Programming
 
Ruby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic IntroductionRuby 1.9.3 Basic Introduction
Ruby 1.9.3 Basic Introduction
 
Zero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for youZero, one, two, Freddy's coming for you
Zero, one, two, Freddy's coming for you
 
JavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft TrainingJavaScript Basics - GameCraft Training
JavaScript Basics - GameCraft Training
 
js.pptx
js.pptxjs.pptx
js.pptx
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Swift Basics with iOS 8 features
Swift Basics with iOS 8 featuresSwift Basics with iOS 8 features
Swift Basics with iOS 8 features
 
Web Languages
Web LanguagesWeb Languages
Web Languages
 
Languages (1)
Languages (1)Languages (1)
Languages (1)
 

Plus de Netguru

Coffeescript presentation DublinJS
Coffeescript presentation DublinJSCoffeescript presentation DublinJS
Coffeescript presentation DublinJS
Netguru
 
Barcamps in Europe
Barcamps in EuropeBarcamps in Europe
Barcamps in Europe
Netguru
 
Wiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in RailsWiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in Rails
Netguru
 
Barcamp #5 - API
Barcamp #5 - APIBarcamp #5 - API
Barcamp #5 - API
Netguru
 
Barcamp #5 - Mikrocelebryci
Barcamp #5 - MikrocelebryciBarcamp #5 - Mikrocelebryci
Barcamp #5 - Mikrocelebryci
Netguru
 

Plus de Netguru (14)

Estimation myths debunked
Estimation myths debunkedEstimation myths debunked
Estimation myths debunked
 
Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?
 
Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)
 
The Git Basics
The Git BasicsThe Git Basics
The Git Basics
 
From nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on RailsFrom nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on Rails
 
Working With Teams Across The Borders
Working With Teams Across The BordersWorking With Teams Across The Borders
Working With Teams Across The Borders
 
Front-End Dev Tools
Front-End Dev ToolsFront-End Dev Tools
Front-End Dev Tools
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
 
Coffeescript presentation DublinJS
Coffeescript presentation DublinJSCoffeescript presentation DublinJS
Coffeescript presentation DublinJS
 
Developing a webdevelopment company
Developing a webdevelopment companyDeveloping a webdevelopment company
Developing a webdevelopment company
 
Barcamps in Europe
Barcamps in EuropeBarcamps in Europe
Barcamps in Europe
 
Wiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in RailsWiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in Rails
 
Barcamp #5 - API
Barcamp #5 - APIBarcamp #5 - API
Barcamp #5 - API
 
Barcamp #5 - Mikrocelebryci
Barcamp #5 - MikrocelebryciBarcamp #5 - Mikrocelebryci
Barcamp #5 - Mikrocelebryci
 

Dernier

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
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Everyday Rails