This document discusses Ruby, an object-oriented scripting language, and its integration with Java via JRuby. It provides an overview of Ruby concepts like classes, modules, and metaprogramming. It then discusses how JRuby allows embedding Ruby as a scripting language in Java applications and using Java classes from Ruby. It also covers Ruby on Rails and how JRuby can be used to deploy Rails applications on the JVM. Finally, it discusses performance improvements in JRuby 1.7 and some benefits of using JRuby.
25. Ruby on Rails
Web applications development framework
Model View Controller (MVC) architecture
Convention over Configuration
Don’t Repeat Yourself (DRY)
Focused on developer productivity
Agile software development approach
26. MVC Architecture
Request Router Database
SQL
Browser
Response
Action Active
Controller Record
Action
View
27. ActiveRecord (Model)
class CreatePosts < ActiveRecor::Migration
def self.up
create_table :posts do |t| CREATE TABLE posts (
t.string :title id NUMBER(38) NOT
t.text :body NULL,
t.timestamps title VARCHAR2(255),
end body CLOB,
end created_at DATE,
end updated_at DATE
);
CREATE SEQUENCE posts_seq;
class Post < ActiveRecord::Base
# nothing here!
end
post = Post.new
post.title = "First post"
post.save
post = Post.find(1)
puts post.name # output: "First post"
28. ActionController
class PostsController < ApplicationController
# GET /posts
def index
@posts = Post.all
end
# GET /posts/1
def show
@post = Post.find(params[:id])
end
# GET /posts/new
def new
@post = Post.new
end
# ...
end
41. JRuby Benefits
Easy to learn for Java programmers
Easy to mix Ruby and Java
Useful frameworks and libraries
Higher productivity for many tasks
Ruby community