ruby on rails intro

Post on 15-May-2015

785 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

An introduction of Ruby on Rails for non-programmers.

TRANSCRIPT

Ruby on RailsRuby on RailsA Basic Introduction for

Non-programmers

Mason Changchangmason@gmail.com

What is it?What is it?

++

Before we start!Before we start!Let’s talk about…

What is Programming?What is Programming?

• Make the computer work for you in a systematic way based on pre-defined rules

• The more trivial routines you have, the more powerful the computer can be

• Depending on the level of abstraction, there are high-level and low-level programming languages

• No matter what language you use, there are commonly 5 types of statements

They are..They are..• Calculations

=> arithmetic or logical operations• Assignments

=> set a name to memorize something• Conditionals

=> if, unless and cases• Iterations

=> do, while, and until loops• Controls

=> sending hardware signals

What is Web?What is Web?

• A client-server computing model, of which data transmission is based on the request-response protocol (HTTP)

• The packets are sent in text without encryption• Stateless nature, connection open and close in every

request-response cycle• No request, no response

RubyRuby

Ruby LanguageRuby Language

• Created by Yukihiro Matsumoto(aka. Matz) in 1993• Flexible syntax, make programmers happy• Dynamic typing, everything is an object• Support both OOP and FP styles• Powerful meta-programming capabilities• Good for constructing DSL• Encourage software test• Site: http://www.ruby-lang.org/

RailsRails

Rails FrameworkRails Framework• Created by David H. Hansson(aka. DHH) in 2004• Full stack framework• MVC design patterns• Support RESTful architecture• Convention Over Configuration• Don’t Repeat Yourself• Encourage Agile methodology• Site: http://rubyonrails.org/

Full StackFull Stack

• Built-in app server• Model => ActiveRecord• Controller => ActionController• View => ActionView• Mailer => ActionMailer• Database adapters• Test cases and fixtures support

Model-View-ControllerModel-View-Controller

Convention Over ConfigurationConvention Over Configuration

• Project files layout => all your code goes in app/ => configuration files in config/ => database migrations in db/ => other libraries in lib/ => static resource files in public/ => app test files in test/

• Naming conventions => table name map to model name => column name map to model attribute name => controller action map to view template

Don’t Repeat YourselfDon’t Repeat Yourself

• Code generators => generate project => generate model with db migration => generate controller with views

• Handy helper methods => JavaScript helpers => Form helpers

• Sensible core extensions• Rake automation tasks• Use plug-ins and gems

top related