SlideShare une entreprise Scribd logo
1  sur  20
Me Breccan McLeod-Lundy Developer at 3months Recent projects include: consumer.org.nz, digitalnz.org and sponsafier.com
Ruby(is not rails) Variables i = 3 i * 4 etc
Iterating and blocks i = [1,2] i.each do |one_i| Something End i.each do { |i| something }
Classes class  Hello def hi puts “hello” end end
Classes(cont) hello_object = Hello.new hello.hi # hello
If blocks if something stuff elsif something_else Other stuffe else Other other stuff end
Ranges and symbols (1...80) is a range contains everything within it and can be iterated over. Colons start symbols which are minimal bits of data representing only themselves, often used as keys in hashes. :symbol
Rails Started 2004 Included in Mac OS X by default in 2006 Recently: twitter, ravelry etc.
Opinionated Sensible Defaults Don't Repeat Yourself
 
Generators rails appname script/generate model/controller name script/generate migration migration
Scaffold generation Not really my first choice, but good for demonstrations and prototyping. script/generate scaffold Movie name:string description:text
Migrations Go up and down add_column :table, :name, type remove_column :table, :name
Routes Create restful routes for a controller map.resources :controller_name Make default page the index map.root :controller => 'movies', :action => 'index (may also need to delete index.html in public)
Adding Reviews script/generate scaffold Review rating:integer movie_id:integer content:text In movie model add has_many :reviews In review model add belongs_to :movie
Reviews New method in the controller needs an array of movies to be added to: @movies = Movies.all.collect { |movie| [movie.name, movie.id]} The view needs a select: <%= f.select(:movie, @movies) %>
Partials Major part of reusing code. In a view: <% render :partial => “/reviews/form” %> Create partials with file names like _form.html.erb
Displaying reviews on a film In show method of the movie controller add: @reviews = @movie.reviews  (After setting @movie) In the view <% @reviews.each do |review| %> <%= render :partial => “review”, :locals => { :review => review } %> <% end %> Create the partial or even extract it from the default review show!
Other resources Rails Guides Agile web dev with rails book Railscasts Wellrailed google group Google
Breccan McLeod-Lundy www.breccan.com [email_address] breccan on twitter, github etc

Contenu connexe

Tendances

Python Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part IIPython Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part IIDUSPviz
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyUna Daly
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main functionRumman Ansari
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)akmalfahmi
 

Tendances (7)

JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Python Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part IIPython Programming for ArcGIS: Part II
Python Programming for ArcGIS: Part II
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
8.3 program structure (1 hour)
8.3 program structure (1 hour)8.3 program structure (1 hour)
8.3 program structure (1 hour)
 

En vedette

Leonardo Da Vinci
Leonardo Da VinciLeonardo Da Vinci
Leonardo Da VinciM.F.R
 
El alquimista 10 c (2)
El alquimista 10 c (2)El alquimista 10 c (2)
El alquimista 10 c (2)Juanmaloko
 
Sistema monitorización ofertix
Sistema monitorización ofertixSistema monitorización ofertix
Sistema monitorización ofertixJoan Valduvieco
 
Introducción al desarrollo Android, Sesión 2
Introducción al desarrollo Android, Sesión 2Introducción al desarrollo Android, Sesión 2
Introducción al desarrollo Android, Sesión 2findemor
 
オープン・ソシオ提供コンテンツ説明
オープン・ソシオ提供コンテンツ説明オープン・ソシオ提供コンテンツ説明
オープン・ソシオ提供コンテンツ説明Akira Yamaguchi
 

En vedette (10)

Sena delgado
Sena   delgadoSena   delgado
Sena delgado
 
Brik charm
Brik charmBrik charm
Brik charm
 
Android
AndroidAndroid
Android
 
Leonardo Da Vinci
Leonardo Da VinciLeonardo Da Vinci
Leonardo Da Vinci
 
20120725 SukuSuku Scrum
20120725 SukuSuku Scrum20120725 SukuSuku Scrum
20120725 SukuSuku Scrum
 
El alquimista 10 c (2)
El alquimista 10 c (2)El alquimista 10 c (2)
El alquimista 10 c (2)
 
Ficha tecnica
Ficha tecnicaFicha tecnica
Ficha tecnica
 
Sistema monitorización ofertix
Sistema monitorización ofertixSistema monitorización ofertix
Sistema monitorización ofertix
 
Introducción al desarrollo Android, Sesión 2
Introducción al desarrollo Android, Sesión 2Introducción al desarrollo Android, Sesión 2
Introducción al desarrollo Android, Sesión 2
 
オープン・ソシオ提供コンテンツ説明
オープン・ソシオ提供コンテンツ説明オープン・ソシオ提供コンテンツ説明
オープン・ソシオ提供コンテンツ説明
 

Similaire à Rails VUWIT workshop

RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2Rory Gianni
 
Agile Development With Hobo
Agile Development With HoboAgile Development With Hobo
Agile Development With HoboEvarist Lobo
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Railselpizoch
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorialsunniboy
 
Django tutorial
Django tutorialDjango tutorial
Django tutorialKsd Che
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkRyan Weaver
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Cogapp
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails Hung Wu Lo
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à RubyMicrosoft
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven developmentGil Fink
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram FiltersTJ Stalcup
 
Coder Presentation Szeged
Coder Presentation SzegedCoder Presentation Szeged
Coder Presentation SzegedDoug Green
 
Rails Rookies Bootcamp - Blogger
Rails Rookies Bootcamp - BloggerRails Rookies Bootcamp - Blogger
Rails Rookies Bootcamp - BloggerNathanial McConnell
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Joomla Day Austin Part 4
Joomla Day Austin Part 4Joomla Day Austin Part 4
Joomla Day Austin Part 4Kyle Ledbetter
 

Similaire à Rails VUWIT workshop (20)

Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
Agile Development With Hobo
Agile Development With HoboAgile Development With Hobo
Agile Development With Hobo
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
What Is Hobo ?
What Is Hobo ?What Is Hobo ?
What Is Hobo ?
 
Actionview
ActionviewActionview
Actionview
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
Django tutorial
Django tutorialDjango tutorial
Django tutorial
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 Framework
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à Ruby
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Build Your Own Instagram Filters
Build Your Own Instagram FiltersBuild Your Own Instagram Filters
Build Your Own Instagram Filters
 
Coder Presentation Szeged
Coder Presentation SzegedCoder Presentation Szeged
Coder Presentation Szeged
 
Rails Rookies Bootcamp - Blogger
Rails Rookies Bootcamp - BloggerRails Rookies Bootcamp - Blogger
Rails Rookies Bootcamp - Blogger
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Joomla Day Austin Part 4
Joomla Day Austin Part 4Joomla Day Austin Part 4
Joomla Day Austin Part 4
 

Dernier

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
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
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
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...apidays
 
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.pdfOrbitshub
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 

Dernier (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 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
 

Rails VUWIT workshop

  • 1. Me Breccan McLeod-Lundy Developer at 3months Recent projects include: consumer.org.nz, digitalnz.org and sponsafier.com
  • 2. Ruby(is not rails) Variables i = 3 i * 4 etc
  • 3. Iterating and blocks i = [1,2] i.each do |one_i| Something End i.each do { |i| something }
  • 4. Classes class Hello def hi puts “hello” end end
  • 5. Classes(cont) hello_object = Hello.new hello.hi # hello
  • 6. If blocks if something stuff elsif something_else Other stuffe else Other other stuff end
  • 7. Ranges and symbols (1...80) is a range contains everything within it and can be iterated over. Colons start symbols which are minimal bits of data representing only themselves, often used as keys in hashes. :symbol
  • 8. Rails Started 2004 Included in Mac OS X by default in 2006 Recently: twitter, ravelry etc.
  • 9. Opinionated Sensible Defaults Don't Repeat Yourself
  • 10.  
  • 11. Generators rails appname script/generate model/controller name script/generate migration migration
  • 12. Scaffold generation Not really my first choice, but good for demonstrations and prototyping. script/generate scaffold Movie name:string description:text
  • 13. Migrations Go up and down add_column :table, :name, type remove_column :table, :name
  • 14. Routes Create restful routes for a controller map.resources :controller_name Make default page the index map.root :controller => 'movies', :action => 'index (may also need to delete index.html in public)
  • 15. Adding Reviews script/generate scaffold Review rating:integer movie_id:integer content:text In movie model add has_many :reviews In review model add belongs_to :movie
  • 16. Reviews New method in the controller needs an array of movies to be added to: @movies = Movies.all.collect { |movie| [movie.name, movie.id]} The view needs a select: <%= f.select(:movie, @movies) %>
  • 17. Partials Major part of reusing code. In a view: <% render :partial => “/reviews/form” %> Create partials with file names like _form.html.erb
  • 18. Displaying reviews on a film In show method of the movie controller add: @reviews = @movie.reviews (After setting @movie) In the view <% @reviews.each do |review| %> <%= render :partial => “review”, :locals => { :review => review } %> <% end %> Create the partial or even extract it from the default review show!
  • 19. Other resources Rails Guides Agile web dev with rails book Railscasts Wellrailed google group Google
  • 20. Breccan McLeod-Lundy www.breccan.com [email_address] breccan on twitter, github etc