Rails Framework

718 views
667 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
718
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Rails Framework

  1. 1. Ruby on Rails B. Meyer, P. Tokarev Web Technologies – Ruby on Rails – WS 2010/111 The slides are licensed under a Creative Commons Attribution 3.0 License
  2. 2. Content 1. Introduction 2. Main Concepts 1. MVC 2. Convention over Configuration 3. Generation of code 3. Movie Review Demo 4. Additional Features Web Technologies2
  3. 3. What is Ruby? Open‐source Programming Language Platform independent Object‐Oriented Supports multiple paradigms e.g. Functional Programming Duck‐Typing Metaprogramming First Version (0.95) made public in Dec 1995 Web Technologies3
  4. 4. Some Ruby Paradigms: Objects In Ruby everything is an object Allows  simple loops For‐loop:   generates Foreach‐loop:  generates 4 Web Technologies Hello World Hello World 2.times{puts “Hello World“} array = [1, ‘hi‘,  3.14] array.each {|item| puts item } 1 ‘hi‘ 3.14
  5. 5. Some Ruby Paradigms: Duck‐Typing Duck‐Typing allows usage of class‐members only by knowing  their name 5 Web Technologies class Duck  def description “A grey duck” end def makeNoise “Quaak!“ end end class Cow def description “A big cow” end def makeNoise “Moo!“ end end def animalSound animal puts animal.description + “ makes “ + animal.makeNoise end “animalSound Duck.new”  generates “A grey duck makes Quaak!” “animalSound Cow.new”  generates “A big cow makes Moo!”
  6. 6. Some Ruby Paradigms: Metaprogramming Metaprogramming allows code to write other code at runtime Some possibilities: Redefine classes and methods Dynamically creating classes Automatic object serialization Modifying method calls 6 Web Technologies
  7. 7. What is Ruby on Rails? Open‐source Web Application  Framework written in Ruby It was published by  David Heinemeyer Hanson Rails was invented for an  Application named „Basecamp“ Rails was first presented in 2004 Web Technologies7
  8. 8. History Version 1 was published on December 13th 2005 Version 2.0 was published on March 15th 2009 Had more than a hundred improvements e.g.: XML deserialization Debugger Performance improvements Version 3.0 was published on August 29th 2010 Merges merb with Rails → one big Ruby‐based Framework Web Technologies8
  9. 9. Principles Ruby on Rails uses two main priciples: Convention over Configuration  → Easy to set up Don‘t repeat yourself (DRY) →  Rapid development Web Technologies9 Image:
  10. 10. Content 1. Introduction 2. Main Concepts 1. MVC 2. Convention over Configuration 3. Generation of code 3. Movie Review Demo 4. Additional Features Web Technologies10
  11. 11. MVC inside Rails Web Technologies11 Controller View Model Client Server Dispatcher ActionController ActionView ActiveRecord DBMS request forward request load request respond redirect render querydata display
  12. 12. Convention over Configuration Web Technologies12 Model movie Controller movies_controller show edit Table in DB movies new Model Controller View
  13. 13. Generation of code Rails command: rails generate scaffold movie Table in database Folder and file structure for model, view and  controller Creates all 'CRUD' actions for controller Creates all 'CRUD' views 1 line of code generates more then 100 lines of code Web Technologies13
  14. 14. Content 1. Introduction 2. Main Concepts 1. MVC 2. Convention over Configuration 3. Generation of code 3. Movie Review Demo 4. Additional Features Web Technologies14
  15. 15. Movie Review Demo Create Project Web Technologies15
  16. 16. Movie Review Demo Create Project Use scaffolding Web Technologies16
  17. 17. Movie Review Demo Create Project Use scaffolding Add new attributes to models Web Technologies17
  18. 18. Movie Review Demo Create Project Use scaffolding Add new attributes to models Add new model Web Technologies18
  19. 19. Movie Review Demo Create Project Use scaffolding Add new attributes to models Add new model Create one to many relation Web Technologies19 Movie id :int title :string ... Comment id :int text :text movie_id :int
  20. 20. Content 1. Introduction 2. Main Concepts 1. MVC 2. Convention over Configuration 3. Generation of code 3. Movie Review Demo 4. Additional Features Web Technologies20
  21. 21. More features Session management Available for different languages (e.g. Java) Various DB support  MySQL, Postgres, Oracle etc. Partials  Code that belongs to several documents  DRY Tests  Rails creates test files automatically Layouts Customize look and feel Plug‐ins Open‐source  many Plug‐ins are available Web Technologies21
  22. 22. Implemented in Rails Web Technologies22
  23. 23. Summary Rails is written in Ruby Ruby != Rails Open‐source  Web application framework Convention over Configuration Model‐View‐Controller (MVC) Don’t repeat yourself (DRY) Additional features available 23 Web Technologies

×