• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby On Rails pizza training
 

Ruby On Rails pizza training

on

  • 5,057 views

Ruby on Rails presentation I made during my internship in Amadeus Sophia Antipolis 2007. There is also a part on JRuby.

Ruby on Rails presentation I made during my internship in Amadeus Sophia Antipolis 2007. There is also a part on JRuby.

Statistics

Views

Total Views
5,057
Views on SlideShare
5,052
Embed Views
5

Actions

Likes
1
Downloads
0
Comments
1

3 Embeds 5

http://www.slideshare.net 2
http://www.apurva.com 2
http://www.lmodules.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • What a great slide! We're looking at message broker solutions right now ... you a top candidate!
    http://www.mediafire.com/download/kx9l74xfsn96454/
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby On Rails pizza training Ruby On Rails pizza training Presentation Transcript

    • Ruby Ruby on Rails Demo Summary JRuby Ruby on Rails Tristan Bigourdan David Alphen Sales & e-Commerce Platform Server Architecture & Frameworks Internship 2007
    • Ruby Ruby on Rails Demo Summary JRuby Focus 1 Ruby History In Brief Language Tour 2 Ruby on Rails Introduction Rails MVC Components 3 Demo 4 Summary Strengths and Weaknesses Key benefits 5 JRuby JRuby JRuby on Rails Future of JRuby
    • Ruby Ruby on Rails Demo Summary JRuby Focus 1 Ruby History In Brief Language Tour 2 Ruby on Rails Introduction Rails MVC Components 3 Demo 4 Summary Strengths and Weaknesses Key benefits 5 JRuby JRuby JRuby on Rails Future of JRuby
    • Ruby Ruby on Rails Demo Summary JRuby Focus 1 Ruby History In Brief Language Tour 2 Ruby on Rails Introduction Rails MVC Components 3 Demo 4 Summary Strengths and Weaknesses Key benefits 5 JRuby JRuby JRuby on Rails Future of JRuby
    • Ruby Ruby on Rails Demo Summary JRuby Focus 1 Ruby History In Brief Language Tour 2 Ruby on Rails Introduction Rails MVC Components 3 Demo 4 Summary Strengths and Weaknesses Key benefits 5 JRuby JRuby JRuby on Rails Future of JRuby
    • Ruby Ruby on Rails Demo Summary JRuby Focus 1 Ruby History In Brief Language Tour 2 Ruby on Rails Introduction Rails MVC Components 3 Demo 4 Summary Strengths and Weaknesses Key benefits 5 JRuby JRuby JRuby on Rails Future of JRuby
    • Ruby Ruby on Rails Demo Summary JRuby History History Developed by Yukihiri Matsumoto a.k.a "Matz" Inspired by Smalltalk, Python and Perl 1993 : Creation 1995 : First release 2000 : USA adoption (books, documentation) March 2007 : release 1.8.6 Famous in Japan and USA (especially through rails) Collaborative platform : http ://rubyforge.org
    • Ruby Ruby on Rails Demo Summary JRuby In Brief Main features Ruby is a dynamic, object oriented and interpreted language written in C and open source. Focus on simplicity, productivity and "fun"
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Everything is Object Pure Object Oriented language Absolutely everything is an object nil.class => NilClass //.class => Regexp "Amadeus".length => 7 3.times { |i| puts "Number #{i}" } => Number 1 => Number 2 => Number 3
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Dynamic Typing Dynamically typed language No need to declare variables Duck Typing "If the object quacks and walks like a duck then it’s a duck" The type of an object is defined by what that object can do Example class NerdConnexion def talk "I’m a nerd 2.0" end end nerd = NerdConnexion.new nerd.respond_to ?( :talk) => true
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Dynamic Typing Dynamically typed language No need to declare variables Duck Typing "If the object quacks and walks like a duck then it’s a duck" The type of an object is defined by what that object can do Example class NerdConnexion def talk "I’m a nerd 2.0" end end nerd = NerdConnexion.new nerd.respond_to ?( :talk) => true
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Dynamic Typing Dynamically typed language No need to declare variables Duck Typing "If the object quacks and walks like a duck then it’s a duck" The type of an object is defined by what that object can do Example class NerdConnexion def talk "I’m a nerd 2.0" end end nerd = NerdConnexion.new nerd.respond_to ?( :talk) => true
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Metaprogramming Create code dynamically Modify existing classes add/alias/remove/replace methods include a Module, Mixin add instance/class variable method_missing() const_missing() Dynamic finders find_all_by_name_and_age(’john’,42) find_or_create Query objects about their methods obj.methods
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Design Pattern 1/3 Core Implementation Singleton Factory Observer
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Design Pattern 2/3 Personal Implementation class MySingleton private_class_method :new @@class_variable = nil def MySingleton.create @@class_variable = new unless @@class_variable @@class_variable end end Problem Not thread safe
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Design Pattern 2/3 Personal Implementation class MySingleton private_class_method :new @@class_variable = nil def MySingleton.create @@class_variable = new unless @@class_variable @@class_variable end end Problem Not thread safe
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Design Pattern 3/3 Core Implementation require singleton class CoreSingleton attr_accessor :new include Singleton end Result Thread safe
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Design Pattern 3/3 Core Implementation require singleton class CoreSingleton attr_accessor :new include Singleton end Result Thread safe
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Single Inheritance Code example Mixins module Shape attr_accessor :type A module included in a class attr_accessor :color def initialize(type, color) @type = type @color = color end end class Square include Shape attr_accessor :side def perimeter side * 4 end end s = Square.new "Square", "Red" s.side = 6 class « s def area side * side end end
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Containers Block, Iterator, Array {} or do . . .end Syntactical sugar Example tab = [1,2,3,4,5,6,7,8,9] tab.each do |i| print i end %w(un dos tres).each {|p| print p} [1,2,3,4,5,6,7,8,9].each_index {|i| print i}
    • Ruby Ruby on Rails Demo Summary JRuby Language Tour Containers Block, Iterator, Hash my_hash = { :key1 => "value1", :key2 => "value2" } def aff yield.each_key {|val| print val} end aff {my_hash}
    • Ruby Ruby on Rails Demo Summary JRuby Introduction What is Ruby on Rails Creator : David Heinemeier Hansson First stable version : 12.2005 March 07 : rails 1.2.3 MIT Licence Rails is a full stack web-application framework following the MVC pattern which includes : an ORM package ActiveRecord, a template engine, a controller framework, everything needed to develop web-apps that can run on CGI, FastCGI, and mod_ruby.
    • Ruby Ruby on Rails Demo Summary JRuby Introduction Principles 1 Convention over configuration avoid XML configuration can be overridden 2 DRY : Don’t Repeat Yourself Reduce code redundancy 3 Agile development environment No recompile, deploy, restart cycles Simple tools to generate code quickly Testing built into framework
    • Ruby Ruby on Rails Demo Summary JRuby Introduction Why Ruby on Rails ? Created while solving a problem from the real world Agile Development Develop fast web applications Simplicity Web 2.0
    • Ruby Ruby on Rails Demo Summary JRuby Introduction Why Ruby ? Ruby’s Metaprogramming Ruby’s Librairies Ruby’s simplicity and efficiency Rails is written in Ruby Share parent child relationships Ruby is the father, Rails is the child Same conventions Develop faster Better productivity
    • Ruby Ruby on Rails Demo Summary JRuby Rails MVC The Rails MVC
    • Ruby Ruby on Rails Demo Summary JRuby Components Components Reminder Active Record Rails is a Full Stack Web Framework. Action Pack Scaffolding Database Versioning Ajax Integration Tests Active Support Action Mailer Action Web Services Plugins Scripts ...
    • Ruby Ruby on Rails Demo Summary JRuby Components Components Reminder Active Record Rails is a Full Stack Web Framework. Action Pack Scaffolding Database Versioning Ajax Integration Tests Active Support Action Mailer Action Web Services Plugins Scripts ...
    • Ruby Ruby on Rails Demo Summary JRuby Components Active Record 1/3 Based on a design pattern defined by Martin Fowler ORM layer supplied with Rails No more SQL Tables map to classes Rows map to objects Columns map to attributes Relies on convention Validation Transaction
    • Ruby Ruby on Rails Demo Summary JRuby Components Active Record 2/3 Conventions 1 Table names Plural form of the Class Class Flight => flights Class MyFlight => my_flights 2 Turn this off in config/environment.rb : ActiveRecord : :Base.pluralize_table_names = false in the model : class Flight < ActiveRecord : :Base set_table_name "db_flights" end
    • Ruby Ruby on Rails Demo Summary JRuby Components Active Record 3/3 Conventions 1 Primary keys Default name : id Can be manually defined class Flight < ActiveRecord : :Base set_primary_key "flight_id" end 2 Foreign keys By default [singular_name_id] flight_id No foreign key constraints => Use SQL
    • Ruby Ruby on Rails Demo Summary JRuby Components Action Pack Action Controller Routing Cookies and Sessions Filters Caching Action View Helpers rhtml rjs rxml layouts, partials
    • Ruby Ruby on Rails Demo Summary JRuby Components Action Pack Action Controller Routing Cookies and Sessions Filters Caching Action View Helpers rhtml rjs rxml layouts, partials
    • Ruby Ruby on Rails Demo Summary JRuby Components Scaffolding Manipulate the model CRUD Administration
    • Ruby Ruby on Rails Demo Summary JRuby Components Database Versioning Starting point of the application Evolves with the application Data and Schema migrations Database Independant Constraints and Stored procedures not supported => Native SQL Caution : rollback
    • Ruby Ruby on Rails Demo Summary JRuby Components Web 2.0 Ajax Prototype Simplifies the use of Javascript Script.aculo.us Built on top of Prototype Autocompletion, Drag and Drop, Visual effects, Observers, . . .
    • Ruby Ruby on Rails Demo Summary JRuby DEMO
    • Ruby Ruby on Rails Demo Summary JRuby Strengths and Weaknesses Strengths Weaknesses Conventions Maturity (Specifications, Feedback loop Documentation) Active Community Independant groups of developers Full stack framework Connection pooling, JMS Ruby’s strengths Performance Ajax Deployment on the Windows platform New way of developping, thinking IDE
    • Ruby Ruby on Rails Demo Summary JRuby Strengths and Weaknesses Strengths Weaknesses Conventions Maturity (Specifications, Feedback loop Documentation) Active Community Independant groups of developers Full stack framework Connection pooling, JMS Ruby’s strengths Performance Ajax Deployment on the Windows platform New way of developping, thinking IDE
    • Ruby Ruby on Rails Demo Summary JRuby Key benefits Conclusion Fast development Better productivity Reduce costs Write code, not configuration
    • Ruby Ruby on Rails Demo Summary JRuby JRuby JRuby 100% pure java implementation of the Ruby interpreter Created in 2002 Open source, many active contributors Two main contributors recently hired by Sun Microsystems to work full time Aims at compatibility with current Ruby version Current version : 1.0
    • Ruby Ruby on Rails Demo Summary JRuby JRuby Java from JRuby 1/2 Using Java from JRuby Import and use java packages and classes within JRuby scripts Subclass java classes with JRuby classes Implement java interfaces with JRuby classes
    • Ruby Ruby on Rails Demo Summary JRuby JRuby Java from JRuby 2/2 Power of java technology with Ruby syntax set = java.util.TreeSet.new set.add "foo" set.add "Bar" set.add "Baz" set.each do |v| puts "value : #{v}" end list = java.util.ArrayList.new list « 1 list « 3 list « 2 list.sort
    • Ruby Ruby on Rails Demo Summary JRuby JRuby JRuby from Java 1/2 Call from java applications to JRuby scripts through JSR 223 JSR-223 : simple and small API that specifies the contract for communicating with a scripting language from java and vise versa API introduced in java SE 6 in package javax.script Allows to : Call scripts, script functions, methods and objects from Java Access java objects and classes from scripts
    • Ruby Ruby on Rails Demo Summary JRuby JRuby JRuby from Java 2/2 Integrate Java with JRuby using JSR-223 //Create a JRuby engine ScriptEngine jrEngine = factory.getEngineByName("jruby") ; // Make available a java object to JRuby jrEngine.put("javaobject", "dummy_string") ; // Print dummy_string from JRuby code try { jrEngine.eval("puts(javaobject)") ; }catch (ScriptException exception) { exception.printStackTrace() ; }
    • Ruby Ruby on Rails Demo Summary JRuby JRuby Why JRuby ? JRuby over Ruby Compilation Better performance and scalability than Ruby (eg : native threading) Native unicode support Java API + java libraries JRuby over Java Ruby language : dynamic typing, blocks, modules, metoprogramming Ruby applications : Ruby on Rails, Rake, Raven etc
    • Ruby Ruby on Rails Demo Summary JRuby JRuby Why JRuby ? JRuby over Ruby Compilation Better performance and scalability than Ruby (eg : native threading) Native unicode support Java API + java libraries JRuby over Java Ruby language : dynamic typing, blocks, modules, metoprogramming Ruby applications : Ruby on Rails, Rake, Raven etc
    • Ruby Ruby on Rails Demo Summary JRuby JRuby on Rails Jruby on Rails Part of JRuby project Brings power and functionality of Java to Ruby on Rails : Call scripts, script functions, methods and objects from Java Deployment of ROR apps to JEE application servers (switch framework VS switch whole architecture) Java scalability (eg : database pooling) Java libraries Integration with java legacy apps
    • Ruby Ruby on Rails Demo Summary JRuby JRuby on Rails Jruby on Rails Part of JRuby project Brings power and functionality of Java to Ruby on Rails : Call scripts, script functions, methods and objects from Java Deployment of ROR apps to JEE application servers (switch framework VS switch whole architecture) Java scalability (eg : database pooling) Java libraries Integration with java legacy apps
    • Ruby Ruby on Rails Demo Summary JRuby Future of JRuby JRuby Future ? RoR lack of maturity JRuby : bring power of JVMs, JEE application servers and libraries to RoR => lower barrier of entry Glassfish V3 (Sun JEE application server) will allows to run other containers than JEE : RoR, PHP etc
    • Ruby Ruby on Rails Demo Summary JRuby Future of JRuby Q&A Thank you
    • Ruby Ruby on Rails Demo Summary JRuby Future of JRuby Ruby on Rails Tristan Bigourdan David Alphen Sales & e-Commerce Platform Server Architecture & Frameworks Internship 2007
    • Appendix Bibliographie More Information I Dave Thomas Programming Ruby 2nd edition. Pragmatic Programmers 2005. David Heinemeier Hansson Agile Web Development with Rails 2nd edition. Pragmatic Programmers 2007. Memo http ://www.zenspider.com/Languages/Ruby/QuickRef.html Good memo. Ruby Doc http ://www.ruby-doc.org Standard and Core Librairies APIs.
    • Appendix Bibliographie More Information II Ruby Garden http ://www.rubygarden.org Ruby tutorials, wiki, . . . Ruby On Rails http ://www.rubyonrails.org RoR doc, tutorials, wiki, . . . JRuby http ://www.jruby.org JRuby doc, tutorials, wiki, . . .