Ruby on Rails: Making simple stuff simple “Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and less.

Slides:



Advertisements
Liknende presentasjoner
Design av sikre web-applikasjoner
Advertisements

Everyone Print Kalle Snarheim.
Høgskolen i Oslo Webprogrammering SQL og databaser del 3.
Jara NetBusiness Vedlikeholdsrelease , 11. februar 2008.
DESEMBERKONFERANSEN Kristian Siem SS7 New Vessels
IBM Global Services JavaOne 2007 Ole André Scheie IBM GBS.
Régis Laurent Director of Operations, Global Knowledge Competencies include: Gold Learning Silver System Management Touch, flip and fold Håvard Haukeberg.
Gruppemedlemmer Gruppa består av: Magnus Strand Nekstad – s156159
The Trondheim Toll Ring System
NUUG.topic = Ruby.new Johannes Brodwall Takk til Dave Thomas for bruk av enkelte slides.
Ledelsesinformasjonsystem
Tips og triks MSP og Projectserver 1) Vise prosjektsammendrag
Mobile Phone authorised Services through Near Field Communications Hans-Christian Haugli, Elin Melby, Josef Noll.
Web Services gjennom eksempler Johannes Brodwall.
Strategisk og taktisk SOA Fagforbundet/Sykehuspartner Johannes Brodwall, Ikke virksomhetsarkitekt Steria Norway.
Web Client Software Factory Inge StubdalLevel 300 Avanade.
Key takes from the CXPA breakfast meeting 19th of march 2013 Summarized by KOBRA – Full text from Post It notes available in notes 1.
Gitte Holten Ingerslev - DPU Tekst Forskerens og didaktikerens blik på mødet mellem tekst og læser.
Det er ganske underlig med disse sentrale salmene. Selv om du ikke er religiøs burde du lese dette.
Designing the User Interface (Antall brukere == Antall meninger)
Making a Home Page. Why a Web Page? Easier to submit labs electronically (lack of color printers at university); Easier to submit labs electronically.
Facebook Deling av applikasjoner, bilder, lenker, sider,videoer.
Nettverk Software Protocol Hierarchies
Nettverk Software Protocol Hierarchies
Android-Programmering Våren Lagring av data SharedPreferences Filsystem Database.
Kvalitetssikring av analyser til forskningsbruk
K.Atakan & K.A.Atakan Institute of Solid Earth Physics University of Bergen Allégt.41, N-5007 Bergen, Norway Tel: Fax:
Om Øvelse 7 Stoff relatert til øvelse 7 Generering av tilfeldige tall Bruk ting vi har lært før.
Konseptuell modell Hvordan skal dette se ut ifra brukeren?
Men hva mener de som har klart det? Børge Haugset (NTNU&SINTEF)
1 Information search for the research protocol in IIC/IID Medical Library, 2013.
Copyright © 2003 Systek OOs gjenfødsel? Innlegg til Systek’s teknologisamling Johannes Brodwall.
Copyright © 2003 Systek J2EE Teknologier Java Workshop CBA Johannes Brodwall, Systek as.
Hello Again World Programmering for gøy. Innhold Installasjon av Ruby Oppvarming: Binærsøk Oppgave: Finn anagrammer For de interesserte: Gjenta i C For.
Microsoft for akademia Rune Zakariassen Fagansvarlig for forskning og høyere utdanning Microsoft Norge.
WHY WE’RE STRENGTHENING ROTARY. OBJECTIVES  Clarify what Rotary stands for, how it’s different and why people should care  Elevate awareness and understanding.
ADA 95 – del3 Foreleser: Olaf Hallan Graven Bok: Programming in ADA95 (2nd) John Barnes.
Høgskolen i Oslo Webprogrammering Ajax og PHP. I dag l Hvordan få en bedre brukeropplevelse via Ajax- script l Gjennomgang av kode l Oppgaveløsning på.
Høgskolen i Oslo Webprogrammering Java-scripting 2 Klientvalidering.
Triggere Mutasjoner i basen. Triggers Triggers are stored procedures that execute automatically when something (event) happens in the database: : data.
  Den perfekte julegaven til Javakoden din Johannes Brodwall Steria.
Our drive is your performance. Hägglunds Drives 1 Our drive is your performance. Lokaliseringskriterier for Hägglunds Drives Presentasjon ved Tom Cantero.
Hvordan lage seg en wikispaces Gå til bestem deg for hvilket wikispaces du vil ha (public, protected, private).
Økonomiske forutsetninger Gullfaks landsbyen 2007.
Citation and reference tools for your master thesis
OOT Seminar H-97 CORBA Praktisk del. Valg av ORB implementasjon n Har valgt å bruke Visigenic sin ORB implementsjon n ORB’en er 100% Java kodet n Bygger.
Trondheim 6. mars 2014 Mørke skyer i horisonten?.
INTERNASJONAL PRIVATRETT Lovvalg i kontrakt – uten partenes valg Professor dr. juris Giuditta Cordero Moss.
02 - Java datatyper Grundlæggende om datatyper og variable.
C O M M E N T O R A / S Commentor A/S – Hørkær 24 – 2730 Herlev - Tel : (+45) Fax : (+45) Team System VSS user guide to TFVC.
1 | 2010 Internetteknologi 2 (ITNET2) Kort teknisk ASP.NET introduktion Mandag den 4/ Jesper Tørresø.
State Of The Union – Backend & Desktop –
IT services and support Information to new employees at UIB.
GPS simulator Et C# program som sender data fra en GPS fil til RS232 og simulerer en GPS engine. Tre linjer pr. sekund er satt opp.
Planning and controlling a project Content: Results from Reflection for action The project settings and objectives Project Management Project Planning.
OpenEdge og.NET Jan Kolstad PUG Norway Lillehammer 2004.
The Thompson Schools Improvement Project Process Improvement Training Slides (Current State Slides Only) October 2009.
Primary French Presentation 10 Colours L.I. C’est de quelle couleur?
Radio listening in Norway
Citation and reference tools for your master thesis
The Norwegian Hydrografic Pilot
Eksempel fra Nevrologisk avdeling
Assignment 2 P3, P5, M1, M2, D1 TEAM SPORT
LO2 – Understand Computer Software
1.4 Relations & Functions.
Behind the scene Anders Hattestad ,
Database.
What belongs in state storage API’s?
LCM API Evolution – El Alto ARCHCOM, April 9, 2019
Utskrift av presentasjonen:

Ruby on Rails: Making simple stuff simple “Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and less code than most frameworks spend doing XML sit-ups” –

Eksempel!

Copyright 2005 – Brodwall IT Services (BITS) Litt tall: Library | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | Helpers | 13 | 12 | 0 | 0 | 0 | 0 | | Controllers | 162 | 132 | 6 | 26 | 4 | 3 | | APIs | 0 | 0 | 0 | 0 | 0 | 0 | | Components | 0 | 0 | 0 | 0 | 0 | 0 | | Functionals | 309 | 224 | 10 | 38 | 3 | 3 | | Models | 82 | 65 | 4 | 9 | 2 | 5 | | Units | 176 | 143 | 4 | 24 | 6 | 3 | | Total | 742 | 576 | 24 | 97 | 4 | 3 | Code LOC: 209 Test LOC: 367 Code to Test Ratio: 1:1.8 Views: 27 filer (9 in use) (413 linjer), fordelt på 6 controllere, Arbeidstid: Cirka 2,5 timer

Copyright 2005 – Brodwall IT Services (BITS) Litt tall: Survey | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | Helpers | 17 | 16 | 0 | 0 | 0 | 0 | | Controllers | 317 | 266 | 6 | 52 | 8 | 3 | | APIs | 0 | 0 | 0 | 0 | 0 | 0 | | Components | 0 | 0 | 0 | 0 | 0 | 0 | | Functionals | 440 | 315 | 10 | 50 | 5 | 4 | | Models | 50 | 40 | 5 | 6 | 1 | 4 | | Units | 70 | 50 | 5 | 10 | 2 | 3 | | Total | 894 | 687 | 26 | 118 | 4 | 3 | Code LOC: 322 Test LOC: 365 Code to Test Ratio: 1:1.1 Views: 23 filer (376 linjer), fordelt på 5 controllere, Arbeidstid: Cirka 15 timer (inkludert fikling med doc og notater av alt jeg gjorde)

Rails på 5 minutter En enkel controller og view

Copyright 2005 – Brodwall IT Services (BITS) Rails på 5 minutter »rails library »cd library »start ruby script\server »start »ruby script\generate controller Say »start »scite app/controllers/say_controller.rb def hello; end (REFRESH) »scite./script/../config/../app/views//say/hello.rhtml HELLO WORLD (REFRESH) »scite app/views/say/hello.rhtml (ruby expressions) Dates: »scite app/controllers/say_controller.rb (verdier fra controller) def = = [ 'city', 'person', 'place' { |word| word.capitalize.pluralize } end »scite app/views/say/hello.rhtml (verdier fra controller) Dates:

Copyright 2005 – Brodwall IT Services (BITS) Linking »scite app/views/say/hello.rhtml Click here to say good bye »scite app/controllers/say_controller.rb def goodbye; end »scite./script/../config/../app/views//say/goodbye.rhtml Stop by and say hello again »hello.rhtml (fiks link) Click Stop by and "goodbye" %> to say good bye »goodbye.rhtml (fiks link) Stop by and "hello" %> again »routes.rb map.connect ':controller/:action/:id'

Copyright 2005 – Brodwall IT Services (BITS) Model-view-controller

Rails på 10 minutter En enkel scaffold En generert scaffold

Copyright 2005 – Brodwall IT Services (BITS) Setup database »scite config/database.yml »mysql -u root –p CREATE DATABASE my_development; GRANT ALL on my_development.* to »scite db/create.sql drop table if exists users; drop table if exists books; create table books ( id int primary key not null auto_increment, title varchar(100) not null, author varchar(100) ); create table users ( id int primary key not null auto_increment, username varchar(100) not null, full_name varchar(100) not null, password varchar(100), unique key (username) ); »mysql -u my my_development < db\create.sql

Copyright 2005 – Brodwall IT Services (BITS) Scaffold »ruby script/generate controller books »ruby script/generate model book »scite app/controllers/books_controller.rb scaffold :book »ruby script/generate scaffold user »Remove password »scite app/views/users/list.rhtml »scite app/views/users/show.rhtml

Copyright 2005 – Brodwall IT Services (BITS) Mer info

Copyright 2005 – Brodwall IT Services (BITS) Ajax •Er dette Ajax? –(Nei!!!) •Hva er AJAX? •For det samme i Java: • _PT2http:// _PT2 var obj; function GetDataViaAJAX() { try { obj = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { obj = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e1) { obj = null; } if(obj!=null) { obj.onreadystatechange = ProcessResponse; obj.open("GET", " customerid=" + document.getElementById("DropDownList1").value, true); obj.send(null); } return false; } Fra Using AJAX with ASP.NET

Copyright 2005 – Brodwall IT Services (BITS) Ajax •Er dette Ajax? –Ja •Hva er AJAX? –Asykront –Interaktivt og –Komponentisert <%= link_to_remote "Loan history", :update =>:loan_history, :url => { :action => "show_history", :id } %>

Copyright 2005 – Brodwall IT Services (BITS) Diskusjon •Nå passer Rails? •Når passer Rails ikke? •Hva kan vi lære av Rails? •Hvordan kommer vi til å se "arven fra Rails" i framtiden? •Sammenligning med andre løsninger

Copyright 2005 – Brodwall IT Services (BITS) Når passer Rails? •Når du trenger mye “bang for the buck” •Når Rails stacken passer for dine behov •Når du kun har en web+mail applikasjon

Copyright 2005 – Brodwall IT Services (BITS) Når passer Rails mindre bra? •Når du trenger en moden (= utprøvd) teknologi •Når du regner med mye fikling –I18N –Performance –Legacy databaser •Når du må gjøre store utskiftinger i stacken •Når du ikke driver med web

Copyright 2005 – Brodwall IT Services (BITS) Validering class BookTitle < ActiveRecord::Base has_many :books validates_presence_of :title, :author validates_numericality_of :publication_year, :only_integer => true validates_presence_of :publication_year def validate if not publication_year.nil? publication_year > 1900 or errors.add(:publication_year, "should be after 1900") publication_year <= Time.now.year or errors.add(:publication_year, "should not be in the future") end

Copyright 2005 – Brodwall IT Services (BITS) Relasjoner class Question < ActiveRecord::Base belongs_to :survey has_many :survey_response_answers acts_as_list :scope => :survey has_many :options, :order => 'position‘ # options acts_as_list def to_s description end

Copyright 2005 – Brodwall IT Services (BITS) Hva kan vi lære av Rails •Convention over configuration –Default parametre –Default mapping –Default applikasjonsstack! •Gode kodegeneratorer er ikke onde

Copyright 2005 – Brodwall IT Services (BITS) Ruby POWER •Adding a method to null- pointers •TAKE THAT, C#! >> a = nil => nil >> a.hello NoMethodError: undefined method `hello' for nil:NilClass from (irb):4 >> class NilClass >> def hello; puts "help"; end >> end => nil >> a.hello help => nil