SlideShare a Scribd company logo
JRuby, Ruby, Rails and You
on the Cloud

December 6th, 2010
Who am I?


Hiro Asari
• JRuby Support Engineer at Engine Yard
• hasari@engineyard.com




                                          2
Engine Yard


• Platform as a Service provider
• Ruby on Rails specialists
• http://www.engineyard.com




                                   3
http://thenetworkisthecomputer.com/
                                 4
WHAT IS RUBY ON RAILS?"
AND"
WHY RUBY ON RAILS?


            http://www.flickr.com/photos/88019192@N00/3277925689/


                                                                5
JVM Web Frameworks Surveys


• http://bit.ly/jvm-frameworks-matrix
• http://bit.ly/webmatrixsurveyresults




                                         6
Rails


           ü Is a web application
         framework written in Ruby 


                 http://www.flickr.com/photos/46799485@N00/4386602878


                                                                    7
Ruby quick facts
• Conceived by Yukihiro
  Matsumoto (a.k.a. Matz)
  in 1993
• Object-oriented
  dynamically-typed
  interpreted scripting
  language
• Influenced by Perl,
  Smalltalk, Eiffel and LISP
• External libraries are
  most frequently
  distributed as “gems”


                               8
Rails quick facts
• Conceived by David
  Heinemeier Hansson
  (a.k.a. DHH) in 2004
• Extracted from 37signals’
  “Basecamp” application
• Uses MVC design
  pattern
• Rails 3, released in
  August, 2010, uses
  “Bundler” to manage
  gems.



                              9
Who uses Rails?




                   10
Getting JRuby




http://jruby.org




                    11
NetBeans



http://netbeans.org




                       12
NetBeans (if you have it already)




                                     13
RubyMine



http://jetbrains.com/ruby




                             14
RVM (Ruby Version Manager)


• http://rvm.beginrescueend.com/
• rvm install jruby
• rvm use jruby




                                   15
Rails


         ü Gets you off and running
                    quickly




                                       16
17
jruby -S rails new cloudstock_demo
cd cloudstock_demo
vi Gemfile
jruby -S bundle install
jruby -S bundle exec glassfish




                                     18
$ jruby -S rails new cloudstock_demo -m http://jruby.org
      create
      create README

      create   app
      create   app/controllers/application_controller.rb
      create   app/helpers/application_helper.rb
      create   app/mailers
      create   app/models
      create   app/views/layouts/application.html.erb

      create   public
      create   public/404.html

      create   script/rails
      create   test
      create   test/fixtures

      create   test/test_helper.rb
      create   test/unit

       apply   http://jruby.org
       apply     http://jruby.org/templates/default.rb
        gsub       Gemfile

                                                           19
20
$ jruby script/rails generate scaffold user name:string
calling init (1017e6ac0)
      invoke active_record
      create    db/migrate/20101115150436_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/unit/user_test.rb
      create      test/fixtures/users.yml
       route resources :users
      invoke scaffold_controller
      create    app/controllers/users_controller.rb
      invoke    erb
      create      app/views/users
      create      app/views/users/index.html.erb
      create      app/views/users/edit.html.erb
      create      app/views/users/show.html.erb
      create      app/views/users/new.html.erb
      create      app/views/users/_form.html.erb
      invoke    test_unit
      create      test/functional/users_controller_test.rb
      invoke    helper
      create      app/helpers/users_helper.rb
      invoke      test_unit
      create        test/unit/helpers/users_helper_test.rb
      invoke stylesheets
      create    public/stylesheets/scaffold.css



                                                             21
$ cat db/migrate/20101115150436_create_users.rb
class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :name

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end


                                                  22
Rails


         ü Is descriptive
                         




                             23
class User < ActiveRecord::Base
  validates_length_of :name, :minimum => 5
end




                                             24
Rails


         ü Is tested




                         25
$ find test
test
test/fixtures
test/fixtures/users.yml
test/functional
test/functional/users_controller_test.rb
test/integration
test/performance
test/performance/browsing_test.rb
test/test_helper.rb
test/unit
test/unit/helpers
test/unit/helpers/users_helper_test.rb
test/unit/user_test.rb


                                           26
$ cat test/unit/user_test.rb
require 'test_helper'

class UserTest < ActiveSupport::TestCase
  test "bare user is invalid" do
    u = User.new
    assert !u.valid?
    assert u.errors[:name].any?
  end

  test "user with name shorter than 5 character is invalid" do
    u = User.new(:name => "hi")
    assert !u.valid?
    assert u.errors[:name].any?
  end

  test "user with name with at least 5 character is valid" do
    u = User.new(:name => "hello")
    assert u.valid?
  end
end

                                                                 27
Rails


         ü Is good for agile
              development 




                                28
Rails


         ü Makes you happy
                          




                              29
WHAT ABOUT…




               30
Accessing Java library from Rails


• Generating SVG with Batik
• http://xmlgraphics.apache.org/batik/




                                         31
Example 1: Generating SVG with Batik
   require 'java'
   require 'batik'

   java_import org.apache.batik.svggen.SVGGraphics2D
   java_import org.apache.batik.dom.GenericDOMImplementation

   dom = GenericDOMImplementation.getDOMImplementation
   svg_ns = 'http://www.w3.org/2000/svg'
   doc = dom.createDocument svg_ns, 'svg', nil
   svg_gen = SVGGraphics2D.new( doc )

   svg_gen.set_paint java.awt.Color.send(color)
   svg_gen.fill java.awt.Rectangle.new(10,10,100,100)
   svg_gen.set_paint java.awt.Color.send(text_color)
   svg_gen.draw_string @user.name, 25, 55

   out = java.io.StringWriter.new
   svg_gen.stream(out, true)
   render :inline => out.to_string                                   

                                                               32
Accessing Java library from Rails


• Generating PDF with iText
• http://itextpdf.com/




                                     33
Example 2: Generating PDF with iText
 require 'iText-5.0.5'
 pdf = com.itextpdf.text.Document.new
 para = com.itextpdf.text.Paragraph.new "Hello #{@user.name}"
 file = "#{::Rails.root.to_s}/tmp/pdfs/pdf_demo.pdf”
 out = java.io.FileOutputStream.new file

 com.itextpdf.text.pdf.PdfWriter.get_instance pdf, out
 pdf.open
 pdf.add para
 pdf.close

 render :file => file



              Don’t do this in production code!
                                              


                                                                34
JRuby on Engine Yard AppCloud




                                 35
JRuby on Engine Yard AppCloud — Sign up today!




        http://docs.engineyard.com/beta/home




                                                  36
Testing in more detail


• RSpec http://rspec.info
• Cucumber http://cukes.info
• Celerity http://celerity.rubyforge.org




                                            37
Deployment strategies


•  Glassfish http://glassfish.java.net/ (.WAR)
•  Tomcat http://tomcat.apache.org/ (.WAR)
•  JBoss http://jboss.org/ (.WAR)
•  Jetty http://jetty.codehaus.org/jetty/ (.WAR)
•  Glassfish gem http://rubyforge.org/projects/glassfishgem/ (embedded
   glassfish)
•  Trinidad https://github.com/calavera/trinidad (embedded Tomcat)
•  Torquebox http://torquebox.org/ (embedded JBoss with extras)
•  Google App Engine http://code.google.com/appengine/ (via google-
   appengine gem http://code.google.com/p/appengine-jruby/)
•  Mongrel (outdated)




                                                                        38
Further information


• The Ruby language web site http://ruby-lang.org
• Ruby On Rails web site http://rubyonrails.org
• JRuby web site http://jruby.org
• Engine Yard web site http://engineyard.com
• Using JRuby (Pragmatic Bookshelf)
  http://www.pragprog.com/titles/jruby/using-
  jruby
• Meet Rails 3 (Peep Code)
  https://peepcode.com/products/meet-rails-3-i



                                                    39
Zero to Rails 3


• http://www.engineyard.com/sparkle
• 4-day online training (December 20-23)




                                           40
http://www.flickr.com/photos/10485077@N06/4975546097
                                                  


                                                  41
Thank you!
           



    Contact me
             
hasari@engineyard.com   
  Twitter: @hiro_asari
   Github: BanzaiMan



                            http://www.flickr.com/photos/42033648@N00/372887164
                                                                             

                                                                      42

More Related Content

What's hot (20)

PDF
Rails Performance
Wen-Tien Chang
 
PDF
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Alexis Hassler
 
PDF
Innovation and Security in Ruby on Rails
tielefeld
 
PDF
Using Java from Ruby with JRuby IRB
Hiro Asari
 
PDF
Practical Celery
Cameron Maske
 
PDF
Why Task Queues - ComoRichWeb
Bryan Helmig
 
PDF
Lightweight Webservices with Sinatra and RestClient
Adam Wiggins
 
KEY
Sinatra for REST services
Emanuele DelBono
 
PDF
Debugging on rails
Mykhaylo Sorochan
 
KEY
How and why i roll my own node.js framework
Ben Lin
 
KEY
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
PDF
Celery - A Distributed Task Queue
Duy Do
 
KEY
Ruby on Rails survival guide of an aged Java developer
gicappa
 
PDF
Akka and the Zen of Reactive System Design
Lightbend
 
PDF
Sinatra Rack And Middleware
Ben Schwarz
 
PDF
To Batch Or Not To Batch
Luca Mearelli
 
KEY
Django Celery
Mat Clayton
 
KEY
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Guillaume Laforge
 
PDF
And now you have two problems. Ruby regular expressions for fun and profit by...
Codemotion
 
PDF
Controlling The Cloud With Python
Luca Mearelli
 
Rails Performance
Wen-Tien Chang
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Alexis Hassler
 
Innovation and Security in Ruby on Rails
tielefeld
 
Using Java from Ruby with JRuby IRB
Hiro Asari
 
Practical Celery
Cameron Maske
 
Why Task Queues - ComoRichWeb
Bryan Helmig
 
Lightweight Webservices with Sinatra and RestClient
Adam Wiggins
 
Sinatra for REST services
Emanuele DelBono
 
Debugging on rails
Mykhaylo Sorochan
 
How and why i roll my own node.js framework
Ben Lin
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
Celery - A Distributed Task Queue
Duy Do
 
Ruby on Rails survival guide of an aged Java developer
gicappa
 
Akka and the Zen of Reactive System Design
Lightbend
 
Sinatra Rack And Middleware
Ben Schwarz
 
To Batch Or Not To Batch
Luca Mearelli
 
Django Celery
Mat Clayton
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Guillaume Laforge
 
And now you have two problems. Ruby regular expressions for fun and profit by...
Codemotion
 
Controlling The Cloud With Python
Luca Mearelli
 

Similar to JRuby, Ruby, Rails and You on the Cloud (20)

PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
PDF
JRuby - Programmer's Best Friend on JVM
Raimonds Simanovskis
 
PDF
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
PDF
Web Development using Ruby on Rails
Avi Kedar
 
PDF
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
Shanda innovation institute
 
PDF
Better Framework Better Life
jeffz
 
PDF
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Arun Gupta
 
PDF
Rails - getting started
True North
 
PDF
IJTC%202009%20JRuby
tutorialsruby
 
PDF
IJTC%202009%20JRuby
tutorialsruby
 
KEY
Better framework, better life
Daniel Lv
 
KEY
Intro to Ruby on Rails
rschmukler
 
KEY
Ruby On Rails
Eric Berry
 
PDF
Rails入門與新人實戰經驗分享
wildjcrt
 
PDF
Jaoo Michael Neale 09
Michael Neale
 
PDF
JRuby and Google App Engine
joshsmoore
 
KEY
Why ruby and rails
Reuven Lerner
 
PDF
JRubyConf 2009
John Woodell
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
JRuby - Programmer's Best Friend on JVM
Raimonds Simanovskis
 
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
Web Development using Ruby on Rails
Avi Kedar
 
[.Net开发交流会][2010.06.19]better framework better life(吕国宁)
Shanda innovation institute
 
Better Framework Better Life
jeffz
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Arun Gupta
 
Rails - getting started
True North
 
IJTC%202009%20JRuby
tutorialsruby
 
IJTC%202009%20JRuby
tutorialsruby
 
Better framework, better life
Daniel Lv
 
Intro to Ruby on Rails
rschmukler
 
Ruby On Rails
Eric Berry
 
Rails入門與新人實戰經驗分享
wildjcrt
 
Jaoo Michael Neale 09
Michael Neale
 
JRuby and Google App Engine
joshsmoore
 
Why ruby and rails
Reuven Lerner
 
JRubyConf 2009
John Woodell
 
Ad

Recently uploaded (20)

PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Ad

JRuby, Ruby, Rails and You on the Cloud

  • 1. JRuby, Ruby, Rails and You on the Cloud December 6th, 2010
  • 2. Who am I? Hiro Asari • JRuby Support Engineer at Engine Yard • [email protected] 2
  • 3. Engine Yard • Platform as a Service provider • Ruby on Rails specialists • http://www.engineyard.com 3
  • 5. WHAT IS RUBY ON RAILS?" AND" WHY RUBY ON RAILS? http://www.flickr.com/photos/88019192@N00/3277925689/ 5
  • 6. JVM Web Frameworks Surveys • http://bit.ly/jvm-frameworks-matrix • http://bit.ly/webmatrixsurveyresults 6
  • 7. Rails ü Is a web application framework written in Ruby http://www.flickr.com/photos/46799485@N00/4386602878 7
  • 8. Ruby quick facts • Conceived by Yukihiro Matsumoto (a.k.a. Matz) in 1993 • Object-oriented dynamically-typed interpreted scripting language • Influenced by Perl, Smalltalk, Eiffel and LISP • External libraries are most frequently distributed as “gems” 8
  • 9. Rails quick facts • Conceived by David Heinemeier Hansson (a.k.a. DHH) in 2004 • Extracted from 37signals’ “Basecamp” application • Uses MVC design pattern • Rails 3, released in August, 2010, uses “Bundler” to manage gems. 9
  • 13. NetBeans (if you have it already) 13
  • 15. RVM (Ruby Version Manager) • http://rvm.beginrescueend.com/ • rvm install jruby • rvm use jruby 15
  • 16. Rails ü Gets you off and running quickly 16
  • 17. 17
  • 18. jruby -S rails new cloudstock_demo cd cloudstock_demo vi Gemfile jruby -S bundle install jruby -S bundle exec glassfish 18
  • 19. $ jruby -S rails new cloudstock_demo -m http://jruby.org create create README create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create public create public/404.html create script/rails create test create test/fixtures create test/test_helper.rb create test/unit apply http://jruby.org apply http://jruby.org/templates/default.rb gsub Gemfile 19
  • 20. 20
  • 21. $ jruby script/rails generate scaffold user name:string calling init (1017e6ac0) invoke active_record create db/migrate/20101115150436_create_users.rb create app/models/user.rb invoke test_unit create test/unit/user_test.rb create test/fixtures/users.yml route resources :users invoke scaffold_controller create app/controllers/users_controller.rb invoke erb create app/views/users create app/views/users/index.html.erb create app/views/users/edit.html.erb create app/views/users/show.html.erb create app/views/users/new.html.erb create app/views/users/_form.html.erb invoke test_unit create test/functional/users_controller_test.rb invoke helper create app/helpers/users_helper.rb invoke test_unit create test/unit/helpers/users_helper_test.rb invoke stylesheets create public/stylesheets/scaffold.css 21
  • 22. $ cat db/migrate/20101115150436_create_users.rb class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.timestamps end end def self.down drop_table :users end end 22
  • 23. Rails ü Is descriptive 23
  • 24. class User < ActiveRecord::Base validates_length_of :name, :minimum => 5 end 24
  • 25. Rails ü Is tested 25
  • 27. $ cat test/unit/user_test.rb require 'test_helper' class UserTest < ActiveSupport::TestCase test "bare user is invalid" do u = User.new assert !u.valid? assert u.errors[:name].any? end test "user with name shorter than 5 character is invalid" do u = User.new(:name => "hi") assert !u.valid? assert u.errors[:name].any? end test "user with name with at least 5 character is valid" do u = User.new(:name => "hello") assert u.valid? end end 27
  • 28. Rails ü Is good for agile development 28
  • 29. Rails ü Makes you happy 29
  • 31. Accessing Java library from Rails • Generating SVG with Batik • http://xmlgraphics.apache.org/batik/ 31
  • 32. Example 1: Generating SVG with Batik require 'java' require 'batik' java_import org.apache.batik.svggen.SVGGraphics2D java_import org.apache.batik.dom.GenericDOMImplementation dom = GenericDOMImplementation.getDOMImplementation svg_ns = 'http://www.w3.org/2000/svg' doc = dom.createDocument svg_ns, 'svg', nil svg_gen = SVGGraphics2D.new( doc ) svg_gen.set_paint java.awt.Color.send(color) svg_gen.fill java.awt.Rectangle.new(10,10,100,100) svg_gen.set_paint java.awt.Color.send(text_color) svg_gen.draw_string @user.name, 25, 55 out = java.io.StringWriter.new svg_gen.stream(out, true) render :inline => out.to_string 32
  • 33. Accessing Java library from Rails • Generating PDF with iText • http://itextpdf.com/ 33
  • 34. Example 2: Generating PDF with iText require 'iText-5.0.5' pdf = com.itextpdf.text.Document.new para = com.itextpdf.text.Paragraph.new "Hello #{@user.name}" file = "#{::Rails.root.to_s}/tmp/pdfs/pdf_demo.pdf” out = java.io.FileOutputStream.new file com.itextpdf.text.pdf.PdfWriter.get_instance pdf, out pdf.open pdf.add para pdf.close render :file => file Don’t do this in production code! 34
  • 35. JRuby on Engine Yard AppCloud 35
  • 36. JRuby on Engine Yard AppCloud — Sign up today! http://docs.engineyard.com/beta/home 36
  • 37. Testing in more detail • RSpec http://rspec.info • Cucumber http://cukes.info • Celerity http://celerity.rubyforge.org 37
  • 38. Deployment strategies •  Glassfish http://glassfish.java.net/ (.WAR) •  Tomcat http://tomcat.apache.org/ (.WAR) •  JBoss http://jboss.org/ (.WAR) •  Jetty http://jetty.codehaus.org/jetty/ (.WAR) •  Glassfish gem http://rubyforge.org/projects/glassfishgem/ (embedded glassfish) •  Trinidad https://github.com/calavera/trinidad (embedded Tomcat) •  Torquebox http://torquebox.org/ (embedded JBoss with extras) •  Google App Engine http://code.google.com/appengine/ (via google- appengine gem http://code.google.com/p/appengine-jruby/) •  Mongrel (outdated) 38
  • 39. Further information • The Ruby language web site http://ruby-lang.org • Ruby On Rails web site http://rubyonrails.org • JRuby web site http://jruby.org • Engine Yard web site http://engineyard.com • Using JRuby (Pragmatic Bookshelf) http://www.pragprog.com/titles/jruby/using- jruby • Meet Rails 3 (Peep Code) https://peepcode.com/products/meet-rails-3-i 39
  • 40. Zero to Rails 3 • http://www.engineyard.com/sparkle • 4-day online training (December 20-23) 40
  • 42. Thank you! Contact me [email protected] Twitter: @hiro_asari Github: BanzaiMan http://www.flickr.com/photos/42033648@N00/372887164 42

Editor's Notes

  • #4: Once upon a time, there was a company which declared that “The Network Is The Computer”.These days, it is impossible to think of a computing environment without the network.
  • #6: At Devoxx 2010, Matt Raible surveyed the current status of JVM Web application frameworks.Ruby on Rails (via JRuby) came in #3 of 13 surveyed.Factors considered:Developer ProductivityDeveloper PerceptionLearning CurveProject HealthDeveloper AvailabilityJob TrendsTemplatingComponentsAjaxPlugins or Add-OnsScalabilityTestingi18n and l10nValidationMulti-language Support (Groovy / Scala)Quality of Documentation/TutorialsBooks PublishedREST Support (client and server)Mobile / iPhone SupportDegree of RiskAfollowup survey by another http://sebastien-arbogast.com/2010/11/19/jvm-web-framework-survey-first-results/From a small sample size, Rails came out #1.But really, you need to see for yourself if Rails (or any other Web application framework) works for YOU!
  • #7: “Convention over configuration”
  • #8: The original implementation of Ruby (also called CRuby, or MRI—Matz’s Ruby Interpreter) is implemented.A newer implemenation of the language, such as JRuby and Rubinius, can compile Ruby programs into byte code to execute them.
  • #9: Blog in 15 minutes: http://www.youtube.com/watch?v=Gzj723LkRJY
  • #10: The list might be outdated.Backpack (37 Signals)Cookpad (Recipe sharing site in Japan)Get Satisfaction (Customer service helper)Github (Social code sharing)Hulu (Online video streaming)Oracle Mix (SNS for Oracle professionals)New York Jets (J. E. T. S. Jets, Jets, Jets)Pragmatic BookshelfGrouponLighthouse (Development issue tracker)ZenDesk (Customer Support ticket tracker)
  • #11: http://jruby.org/download1.5.6 was released last Friday (Dec. 3, 2010)1.6 coming later this month or early next year
  • #12: NetBeans
  • #13: You can install and activate Ruby and Rails plugin if you have NetBeans already. (6.9 and later supports Rails 3.)
  • #14: RubyMine
  • #16: “Convention over configuration”In web application development, there are a lot of things that happen over and over.(Setting up MVC, configuring Database connections, laying out directory structures, etc.) Rails aims to make sensible decisions for you, so that you don’t have to make these decisions.You might think it’s constraining at first, but you will soon learn that by allowing you to spend more time thinking about the application itself (rather than “administrivia”) Rails liberates you.
  • #17: These are the commands used in the previous video.
  • #18: It creates a lot of directories and files with boilerplate content.Give -d mysql to use MySQL as the database engine.
  • #19: It creates a lot of directories and files with boilerplate content.
  • #20: Database schema modification is described in Ruby as well.This migration file was generated by the scaffold generator.
  • #21: Rails can be described as a DSL for web application development.
  • #22: It is clear what this piece of code does.
  • #23: Testing is a part of Ruby and Rails culture.
  • #24: Scaffold generator that we ran earlier also created a few files for tests as well.
  • #25: You *could* add test code such as this.You won’t have to test “validates_length_of” in this way, since it is a part of Rails, and, as such, it is very well tested and understood.
  • #26: Here, “agile” means short feedback cycles
  • #27: The bottom line is that Rails makes you happy.
  • #28: JRuby is an implementation of the Ruby language on the JVM. It can interoperate with the vast collection of existing Java libraries.http://vimeo.com/16270284 http://trackernet.org
  • #29: *DEMO 1*
  • #30: This example generates a simple SVG graphics with Batik library. http://xmlgraphics.apache.org/batik/
  • #31: *DEMO 2*
  • #32: This example generates a PDF file through iText. http://itextpdf.com/This is for illustration purposes only. It is not very secure, not is it very scalable.
  • #34: If you’re interested, sign up to be notified.
  • #35: What we did not cover today
  • #36: What we did not cover today:WAR files are created through warbler gem. http://kenai.com/projects/warbler/pages/HomeTorquebox’s (http://torquebox.org) extras include:ActiveMQ and built-in job scheduling supporthttp://jruby-appengine.blogspot.com/
  • #38: Engine Yard is offering an online training course of Rails 3 later this month.
  • #39: Go grab a piece of Cloud.