Download presentation
Presentation is loading. Please wait.
1
Ruby On Rails Rebecca Crabb and Blaine Stancill
2
Ruby Open-Source Programming LanguageOpen-Source Programming Language Created by Yukihiro MatsumotoCreated by Yukihiro Matsumoto Blended parts of other languagesBlended parts of other languages “I wanted a scripting language that was more powerful than Perl and more object-oriented than Python”“I wanted a scripting language that was more powerful than Perl and more object-oriented than Python” Public release in 1995Public release in 1995 Achieved mass acceptance in 2006 with Ruby On RailsAchieved mass acceptance in 2006 with Ruby On Rails
3
Why Ruby? Ruby: puts “Hello World!”Ruby: puts “Hello World!” Java: threeVeryLongLines.weHopeWork…Java: threeVeryLongLines.weHopeWork… Perl: #$<!&;Perl: #$<!&; Lisp: ((a(((b)))c)))Lisp: ((a(((b)))c))) No, But Really…
4
Ruby vs Java Ruby The empty program:The empty program: Basic Getters and SettersBasic Getters and Setters class Circle attr_accessor :radius end Java The empty program:The empty program: Class Test { public static void main(String[] args){} } Basic Getters and SettersBasic Getters and Setters class Circle{ private float radius; public void setRadius(float radius){ this.radius = radius; } public float getRadius(){ return radius; }}
5
Ruby VS JAVA Ruby List:List: stuff = [ ] stuff << “Java”, “Ruby” Java List:List: List languages = new LinkedList (); languages.add(“Java”); languages.add(“Ruby”);
6
Objects Everything is an objectEverything is an object Does not have primitives like JavaDoes not have primitives like Java
7
TypeCasting “If it walks like a duck and talks like a duck, it’s a duck!” The “Duck Typing” philosophyThe “Duck Typing” philosophy Define an object by what it can do, not its typeDefine an object by what it can do, not its type Current set of methods and propertiesCurrent set of methods and properties Variable namingVariable naming var could be a local variablevar could be a local variable @var is an instance variable@var is an instance variable $var is a global variable$var is a global variable
8
Ruby on Rails Open source web application framework for RubyOpen source web application framework for Ruby Designed for Agile developmentDesigned for Agile development Released in July 2004Released in July 2004 In August 2006 Apple announced that it would ship RoR with Mac OS X LeopardIn August 2006 Apple announced that it would ship RoR with Mac OS X Leopard Rails provided a purpose for RubyRails provided a purpose for Ruby Rails using Model-View-Controller architectureRails using Model-View-Controller architecture
9
Philosophy and Design Convention over ConfigurationConvention over Configuration Naming conventionsNaming conventions Class Sale in the model, the corresponding table in database is called sales by defaultClass Sale in the model, the corresponding table in database is called sales by default Less CodeLess Code Don’t Repeat YourselfDon’t Repeat Yourself ScaffoldingScaffolding Automatically create full CRUD support for database tableAutomatically create full CRUD support for database table GeneratorsGenerators Built in scripts to automatically generate parts of frameworkBuilt in scripts to automatically generate parts of framework
10
MVC Pattern
11
Active Record It’s the M in MVCIt’s the M in MVC Handles the automatic mapping of your database tables to your runtime model objectsHandles the automatic mapping of your database tables to your runtime model objects Tables to classesTables to classes Rows to objectsRows to objects Columns to object attributesColumns to object attributes Don’t need to see or use SQLDon’t need to see or use SQL But still can if necessaryBut still can if necessary Relational databaseRelational database
12
Database Access team.rb is our model:team.rb is our model: class Team < ActiveRecord::Base has_many:players has_one:coach belongs_to:conference end Retrieve all the players:Retrieve all the players: @team= Team.find_by_school_and_sport(“unc”,”basketball”) @team.players
13
The Rails way Quick and easy developmentQuick and easy development Built for scalabilityBuilt for scalability Every app is structured the sameEvery app is structured the same Convention over ConfigurationConvention over Configuration Don’t Repeat YourselfDon’t Repeat Yourself
14
ViDeoS
15
More Info ON RoR http://www.ruby-lang.org/en/about/http://www.ruby-lang.org/en/about/http://www.ruby-lang.org/en/about/ http://rubyonrails.org/http://rubyonrails.org/http://rubyonrails.org/ http://onlamp.com/pub/a/onlamp/2005/10/13/wha t_is_rails.html?page=3http://onlamp.com/pub/a/onlamp/2005/10/13/wha t_is_rails.html?page=3http://onlamp.com/pub/a/onlamp/2005/10/13/wha t_is_rails.html?page=3http://onlamp.com/pub/a/onlamp/2005/10/13/wha t_is_rails.html?page=3 http://railstutorial.org/chapters/a-demo-apphttp://railstutorial.org/chapters/a-demo-apphttp://railstutorial.org/chapters/a-demo-app
16
Questions?
17
References http://www.ruby-lang.org/en/about/http://www.ruby-lang.org/en/about/http://www.ruby-lang.org/en/about/ http://rubyonrails.org/http://rubyonrails.org/http://rubyonrails.org/ http://onlamp.com/pub/a/onlamp/2005/10/13/what_is_ rails.html?page=3http://onlamp.com/pub/a/onlamp/2005/10/13/what_is_ rails.html?page=3http://onlamp.com/pub/a/onlamp/2005/10/13/what_is_ rails.html?page=3http://onlamp.com/pub/a/onlamp/2005/10/13/what_is_ rails.html?page=3 http://railstutorial.org/chapters/a-demo-apphttp://railstutorial.org/chapters/a-demo-apphttp://railstutorial.org/chapters/a-demo-app http://slideshare.net/Belighted/ruby-vs-javahttp://slideshare.net/Belighted/ruby-vs-javahttp://slideshare.net/Belighted/ruby-vs-java http://slideshare.net/vishnu/the-top-10-reasons-the-ruby- programming-language-suckshttp://slideshare.net/vishnu/the-top-10-reasons-the-ruby- programming-language-suckshttp://slideshare.net/vishnu/the-top-10-reasons-the-ruby- programming-language-suckshttp://slideshare.net/vishnu/the-top-10-reasons-the-ruby- programming-language-sucks http://en.wikipedia.org/wiki/Diamond_problemhttp://en.wikipedia.org/wiki/Diamond_problemhttp://en.wikipedia.org/wiki/Diamond_problem
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.