Top Banner
1 Intro to Ruby on Rails Ruby Hellug – 4th of Jan 2014 Eleni Chourouzidou ([email protected])
21

Ruby hellug

May 10, 2015

Download

Technology

Ruby on Rails intro - 4th of January 2014 - Ruby Hellug
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ruby hellug

1Intro to Ruby on Rails

Ruby Hellug – 4th of Jan 2014Eleni Chourouzidou ([email protected])

Page 2: Ruby hellug

Brief History

Ruby Ruby on Rails

2

Page 3: Ruby hellug

Framework Organizes code Provides tools Automates tasks

3

Page 4: Ruby hellug

Brief timeline

1993: Beginning of Ruby 1995: Ruby's first release 1999: Ruby's english documentation 2004: Creation of Ruby on Rails Today: Ruby version 2.1, RoR version

4.0.2

4

Page 5: Ruby hellug

Clean & elegant syntax

> 2.times { print 'We love Ruby!' }

> We love Ruby!We love Ruby! => 2

5

Page 6: Ruby hellug

New app, file structure

> rails new blog> cd blog> rails server

Already a functional application!!

6

Page 7: Ruby hellug

Scaffold: Fast functionality 7

Page 8: Ruby hellug

MVC8

Page 9: Ruby hellug

db/migrate/20140101225451_add_author_to_posts.rb

Migrations9

Page 10: Ruby hellug

Model Validations

10

Page 11: Ruby hellug
Page 12: Ruby hellug

Controller 12

Page 13: Ruby hellug
Page 14: Ruby hellug

Routes & RESTful routing

14

config/routes.rb

Page 15: Ruby hellug

Routes & RESTful routing

15

Page 16: Ruby hellug

What to see next

16

Codeschool Free Course: Rails for Zombies www.railsforzombies.org

Tutorial: Creating a simple ToDo application www.arubystory.blogspot.gr

Book: Rails 4 in Action (Publication 28 Mar 2014)

Page 17: Ruby hellug

Any Questions?

Thank you!

17

Page 18: Ruby hellug

18

Page 19: Ruby hellug

Install Ruby 2Install gem ‘rails’ in console:

> gem install railsCreate new rails app in console:

> rails new blogChange Directory (get in the app folder)

> cd blog

19

Page 20: Ruby hellug

Start the server > rails s

Visit rails welcome page in the browser:

localhost:3000Create Scaffold Post, in the console:

> rails g scaffold post title:string body:text

20

Page 21: Ruby hellug

Run migration = create db table: >rake db:migrate

21