The web and programming: an introduction - Simple, short and friendly
The web and programming:an introduction Simple, short and friendly
3 basic questionWhat are web apps and how do they work?What is Ruby, how is it connected to Rails?What is Rails and what can we use it for?
How does the web work?• Let’s take a look at an example: - What happens when I type railsgirls.com into my web browser?
(188.8.131.52) 1) The web browser looks up the IP address of the web site using DNS I want to know more about Wait, I need to ﬁnd Rails Girls the address of the web server with that info.Avtor fotograﬁje: Ed Yourdon
2) The broswers sends a “GET” request to the serverHey, I need info Just a momentabout Rails Girls ... HTTP request GET Host: railsgirls.com j your computerj host server for railsgirls.com
3) The servers respons with a web page, written in HTML language Aha! Found it! response in HTML language jLet me see what tvoj računalnikjthis looks like... host server for railsgirls.com
4) The web browser makes sure the web site is displayed correctly Ta-da! Isn’t this a nice web site?
So, what are wegoing to work on today? j A web app for collecting ideas
If we want tobuild web apps ... j We need to be able to talk to the sushi chef on the server
Ruby is one of the programminglanguages that we can use in web apps If you want me to do something, you’ve got to speak Ruby! Other popular languages: PHP, Python, Java, ASP.NET, Perl ...
How we can use Ruby to talk to a computer?As a starting point:1) We need to have Ruby installed (Installation Party!)2) Use Terminal or Command Prompt (Windows)
Simple exampleLet’s use irb = Interactive RuBy “Rails Girls”
irb examples"Rails Girls" # strings2+2 # integers2*2 # Ruby as a simple calculator"Rails " * 2 # multiplying a string"Rails " + "Girls" # combining two string"Rails" * "Girls" # multiplying strings doesn’t work"Rails Girls".length # but string do have their own useful methods"Rails Girls".reverseime = "Rails Girls" # to simplify work, we can store objects into variablesime.length # same method as before used on a variable, same resultime.reverseime.upcaseime.downcaseime + ime # variables can also be combined, just like before
Simple exampleLet’s save a program into a .rb ﬁle for easy access Sublime Text 2 Terminal
... the app will be made with different text ﬁles with Ruby, HTML and other code
Rails* apps have three basic building blocks MVC architecture = Model | View | Controller Controller = sushi chef accepts requests, makes all parts work as a whole Model = ingredients represents database data View = sushi the representation of the result,* And a lot of other web apps in different languages seen by usersPhoto by: Michael Kappel
Confused? No worries :) When programming: • Googling is a must; • copy-paste a valid method; • getting a working result is what really matters. P.S.: Practice makes perfect!
Let’s warm up before we make our own app: getting to know web technologies! My Bentobox Application: Designed by: Storage Logic Backend. Backend. How the application stores data. How the application works. Style and structure Frontend. How the application looks. Infrastructure Backend. How the application runs.