SlideShare uma empresa Scribd logo
1 de 194
Baixar para ler offline
*




     * splash@dei.uc.pt   31	
  March	
  2011	
  
Chapter 0
def	
  what	
  is	
  rails?	
  
	
  	
  'A	
  web	
  framework'	
  
end
Rails was created in 2003
by David Heinemeier Hansson
Who is already on Rails?
Who is already on Rails?
Who is already on Rails?
Who is already on Rails?
Let’s try it out!
Let’s try it out!
Let’s try it out!
Chapter 1
Basic concepts of Rails




§  Support for
§  Follows the                          pattern	

§  Follows the           architectural pattern	

§  Supports
Rails directory structure
Rails directory structure
Rails directory structure




                    Application code, structured
                    following the MVC design
Rails directory structure




                   Application configuration
Rails directory structure
Rails directory structure
Rails directory structure
Rails directory structure




                    Files to manipulate the
                    database
Rails directory structure




                  Documentation
                  for the app
Rails directory structure




                    Static files
                    accessible to
                    the public
Rails directory structure




                Application tests
Rails directory structure



                   Third-party
                   Plugins
Rails directory structure
Bundler



                 next step
          Use Bundler to include and
           install the gems needed
Bundler
Bundler
Chapter 2
Building a simple app




                          Key
                  id        integer
                  value     string
                  state     string
Building a simple app
Building a simple app
Building a simple app
Building a simple app
Building a simple app

§  We now need to
§  This                with our new data model
Building a simple app

§  Let’s delete the default static   page
Building a simple app

§  Run the server!
Building a simple app

§  Root page
Building a simple app

§  Index action
Building a simple app

§  New action
Building a simple app

§  Show action
Building a simple app

§  Edit action
Building a simple app

§  Destroy
Building a simple app         table from “Ruby on Rails Tutorial: Learn Rails by Example”
                                                 available at http://ruby.railstutorial.org/



§  Correspondence between pages and URLs
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails


 The browser
 issues a request
 for the
 URL
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails




Rails routes
to the index
action in the
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails



                                         the                               !
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails                    The index action asks
                                    the Key model to retrieve
                                    all keys (     )
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails




                                                     The Key model
                                                    pulls all the keys
                                                   from the database
Building a simple app      diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                                available at http://ruby.railstutorial.org/



§  MVC in Rails




                        The Key model returns the list
                        of keys to the controller
Building a simple app       diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                                 available at http://ruby.railstutorial.org/



§  MVC in Rails

The controller captures
the keys in the @keys
variable, which is passed
to the
Building a simple app       diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                                 available at http://ruby.railstutorial.org/



§  MVC in Rails

The controller captures
the keys in the @users
variable, which is passed
to the
Building a simple app       diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                                 available at http://ruby.railstutorial.org/



§  MVC in Rails

The controller captures
the keys in the @users
variable, which is passed
to the
Building a simple app   diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                             available at http://ruby.railstutorial.org/



§  MVC in Rails              The view uses embedded Ruby
                              to render the page as HTML
Building a simple app        diagram from “Ruby on Rails Tutorial: Learn Rails by Example”
                                                  available at http://ruby.railstutorial.org/



§  MVC in Rails




                         The controller passes the
                        HTML back to the browser
Building a simple app

§  Where are defined the routes?
Building a simple app

§  Which are the default actions?
Building a simple app   table from “Ruby on Rails Tutorial: Learn Rails by Example”
                                           available at http://ruby.railstutorial.org/



§  RESTful routes
image downloaded from http://wallpaperof.net/retro/
Chapter 4
Simple validations
Simple validations




                     I shouldn’t be able to
                     create a key without
                            or
Simple validations




                     V alue should be unique
Simple validations
Simple validations
Simple validations
Simple validations
Simple validations
Simple validations
Simple validations
Form helpers & builders
Form helpers & builders
Form helpers & builders
Form helpers & builders
Form helpers & builders
Form helpers & builders
Form helpers & builders

§  Let’s try a Form Builder DSL
Form helpers & builders

§  Let’s try a Form Builder DSL - Features
Form helpers & builders

§  Let’s try a Form Builder DSL - Features
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try a Form Builder DSL - Installation
Form helpers & builders

§  Let’s try it out!
Form helpers & builders

§  Let’s try it out!
Form helpers & builders

§  Let’s try it out!
Alternate markup languages
Alternate markup languages

§  Why do views tend to become more and
    more complex?
Alternate markup languages


                             HTML
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Alternate markup languages
Root path
Root path
Root path
Root path
Root path
Root path
Root path
image downloaded from http://wallpaperof.net/retro/
Chapter 5
Adding tournaments
Adding tournaments




          Tournament
                                has many   Key
         key_id       integer
         name         string
         start_date   string
         end_date     string
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding tournaments
Adding value range to states
Adding value range to states
Adding value range to states
Adding value range to states
Adding value range to states
Adding value range to states
Adding value range to states
Adding value range to states
Adding value range to states
Internationalization & localization




      image downloaded from http://wallpaperof.net/retro/
Internationalization & localization
Internationalization & localization
Internationalization & localization
Internationalization & localization
Internationalization & localization
Internationalization & localization
Internationalization & localization
Internationalization & localization
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Route translation
Chapter 6
Web-app-theme
Web-app-theme
Web-app-theme
Web-app-theme
Web-app-theme
Web-app-theme
Chapter 7
Create a button on the keys’ index
page to generate 100 random keys
Create a button on the keys’ index
   page to generate 100 random keys	

hints
Create a button on the keys’ index
page to generate 100 random keys
Create a button on the keys’ index
page to generate 100 random keys
Create a button on the keys’ index
page to generate 100 random keys
Create a button on the keys’ index
page to generate 100 random keys
The end
The end
Give back!
Give back!

    open source projects,	

	

     feedback,	

	

   	

share your knowledge,	

	

   	

    	

your snippets & projects
*




     * splash@dei.uc.pt   31	
  March	
  2011	
  

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Building an API using Grape
Building an API using GrapeBuilding an API using Grape
Building an API using Grape
 
Appcelerator Titanium Alloy
Appcelerator Titanium AlloyAppcelerator Titanium Alloy
Appcelerator Titanium Alloy
 
Ruby On Grape
Ruby On GrapeRuby On Grape
Ruby On Grape
 
Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and Widgets
 
Angular 2 overview in 60 minutes
Angular 2 overview in 60 minutesAngular 2 overview in 60 minutes
Angular 2 overview in 60 minutes
 
Introduction to angular 2
Introduction to angular 2Introduction to angular 2
Introduction to angular 2
 
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
What Is Angular 2 | Angular 2 Tutorial For Beginners | Angular Training | Edu...
 
Ember Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberEmber Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with Ember
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsIntroduction to Sightly and Sling Models
Introduction to Sightly and Sling Models
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Phonegap Day 2016: Ember/JS & Hybrid Apps Tips
Phonegap Day 2016: Ember/JS & Hybrid Apps TipsPhonegap Day 2016: Ember/JS & Hybrid Apps Tips
Phonegap Day 2016: Ember/JS & Hybrid Apps Tips
 
Angular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHEREAngular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHERE
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
Laravel.IO A Use-Case Architecture
Laravel.IO A Use-Case ArchitectureLaravel.IO A Use-Case Architecture
Laravel.IO A Use-Case Architecture
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 

Destaque (8)

rails_tutorial
rails_tutorialrails_tutorial
rails_tutorial
 
Ruby + Rails
Ruby + RailsRuby + Rails
Ruby + Rails
 
Ruby on Rails 5: Top 5 Features
Ruby on Rails 5: Top 5 FeaturesRuby on Rails 5: Top 5 Features
Ruby on Rails 5: Top 5 Features
 
Dev ops.continuous delivery - Ibon Landa (Plain Concepts)
Dev ops.continuous delivery - Ibon Landa (Plain Concepts)Dev ops.continuous delivery - Ibon Landa (Plain Concepts)
Dev ops.continuous delivery - Ibon Landa (Plain Concepts)
 
Rails course day 5
Rails course day 5Rails course day 5
Rails course day 5
 
Ionic Hybrid Mobile Application
Ionic Hybrid Mobile ApplicationIonic Hybrid Mobile Application
Ionic Hybrid Mobile Application
 
Introducción a scrum - Rodrigo Corral (Plain Concepts)
Introducción a scrum - Rodrigo Corral (Plain Concepts)Introducción a scrum - Rodrigo Corral (Plain Concepts)
Introducción a scrum - Rodrigo Corral (Plain Concepts)
 
Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)
 

Semelhante a Learning Rails

Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on rails
pmashchak
 
Building Application With Ruby On Rails Framework
Building Application With Ruby On Rails FrameworkBuilding Application With Ruby On Rails Framework
Building Application With Ruby On Rails Framework
Vineet Chaturvedi
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010
arif44
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
sunniboy
 

Semelhante a Learning Rails (20)

Ruby Rails Web Development.pdf
Ruby Rails Web Development.pdfRuby Rails Web Development.pdf
Ruby Rails Web Development.pdf
 
Aspose pdf
Aspose pdfAspose pdf
Aspose pdf
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on rails
 
TorqueBox
TorqueBoxTorqueBox
TorqueBox
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Building Application With Ruby On Rails Framework
Building Application With Ruby On Rails FrameworkBuilding Application With Ruby On Rails Framework
Building Application With Ruby On Rails Framework
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010Ruby On Rails Seminar Basis Softexpo Feb2010
Ruby On Rails Seminar Basis Softexpo Feb2010
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
Intro to Rails
Intro to RailsIntro to Rails
Intro to Rails
 
A Tour of Ruby On Rails
A Tour of Ruby On RailsA Tour of Ruby On Rails
A Tour of Ruby On Rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Rails request & middlewares
Rails request & middlewaresRails request & middlewares
Rails request & middlewares
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
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
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 

Último

Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Último (20)

Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 

Learning Rails