Monday May 04, 2009
Rails Conf 2009 - Day 1 Trip Report
Rails Conf 2009 started this morning. The first day consists of morning
and afternoon tutorials.
I attended Nick Sieger's JRuby
on Rails tutorial, the slides are available.
A survey in the room showed:
| run
lambda { |env| [ 200, { 'Content-Length' => '2', 'Content-Type' => 'text/html', }, ["hi"] ] } |
| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby
-S rackup [2009-05-04 13:40:18] INFO WEBrick 1.3.1 [2009-05-04 13:40:18] INFO ruby 1.8.6 (2009-03-16) [java] [2009-05-04 13:40:18] INFO WEBrick::HTTPServer#start: pid=90964 port=9292 127.0.0.1 - - [04/May/2009 13:40:27] "GET / HTTP/1.1" 200 2 0.0160 127.0.0.1 - - [04/May/2009 13:40:27] "GET /favicon.ico HTTP/1.1" 200 2 0.0060 127.0.0.1 - - [04/May/2009 13:40:30] "GET /favicon.ico HTTP/1.1" 200 2 0.0100 |
| App
= lambda { |env| [ 200, { 'Content-Length' => '2', 'Content-Type' => 'text/html', }, ["hi"] ] } |
| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby
-S rackup app.rb [2009-05-04 13:43:57] INFO WEBrick 1.3.1 [2009-05-04 13:43:57] INFO ruby 1.8.6 (2009-03-16) [java] [2009-05-04 13:43:57] INFO WEBrick::HTTPServer#start: pid=90990 port=9292 127.0.0.1 - - [04/May/2009 13:44:09] "GET / HTTP/1.1" 200 2 0.0110 |
| class
BasicRack def call(env) body = "Hello from a class" [ 200, { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/html', }, [body] ] end end run BasicRack.new |

| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby -S gem install shotgun JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed configuration-0.0.5 Successfully installed launchy-0.3.3 Successfully installed shotgun-0.2 3 gems installed Installing ri documentation for launchy-0.3.3... Installing RDoc documentation for launchy-0.3.3... |
| ~/samples/railsconf/sinatra/basic-rack
>~/tools/jruby/bin/jruby -J-Djruby.fork.enabled=true -S shotgun [2009-05-04 13:55:46] INFO WEBrick 1.3.1 [2009-05-04 13:55:46] INFO ruby 1.8.6 (2009-03-16) [java] == Shotgun starting Rack::Handler::WEBrick on localhost:9393 [2009-05-04 13:55:46] INFO WEBrick::HTTPServer#start: pid=91089 port=9393 |
| class
BasicRack def call(env) body = if env["PATH_INFO"] == "/foo" "in foo" else "in other" end [ 200, { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/html', }, [body] ] end end run BasicRack.new |
| class
BasicRackApp def call(env) body = "hello from app" [ 200, { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/html', }, [body] ] end end class MyMiddleware def initialize(app) @app = app end def call(env) @app.call(env) end end use MyMiddleware run BasicRackApp.new |
| use Rack::CommonLogger |
|
def call(env) status, headers, body = @app.call(env) body.map! { |part| part.upcase} [status, headers, body] end |
| require
'sinatra' |
| ~/samples/railsconf/sinatra/basic-sinatra
>~/tools/jruby/bin/jruby
-rubygems basic-sinatra.rb == Sinatra/0.9.1.1 has taken the stage on 4567 for development with backup from WEBrick [2009-05-04 14:40:14] INFO WEBrick 1.3.1 [2009-05-04 14:40:14] INFO ruby 1.8.6 (2009-03-16) [java] [2009-05-04 14:40:14] INFO WEBrick::HTTPServer#start: pid=91396 port=4567 |
| require
'rubygems' require 'sinatra' not_found do 'hi from other' end get '/foo' do 'hi from foo' end |
| require
'rubygems' require 'sinatra' get '/env' do env.inspect end |
| require
'rubygems' require 'sinatra' get '/' do end post '/' do end put '/' do end delete '/' do end |
| require
'rubygems' require 'sinatra' get '/' do content_type "application/json" { "foo" => "goo" }.to_json end |
| <html> <body> Hello form Sinatra + ERB </body> </html> |
| require
'rubygems' require 'sinatra' get '/' do erb :index end |
| require
'rubygems' require 'sinatra' require 'haml' get '/' do haml :index end |
| %html %body %h1 Hello from HAML |
| require
'rubygems' require 'sinatra' require 'haml' get '/' do erb :index end use_in_file_templates! __END__ @@ index <html> <body> Hello form Sinatra + ERB in file </body> </html> |
| require
'rubygems' require 'sinatra' require 'haml' get '/' do erb :index end get '/foo' do erb :foo end use_in_file_templates! __END__ @@ index <html> <body> Hello form Sinatra + ERB in file </body> </html> @@ foo <h1>FOO!</h1> |
| require
'rubygems' require 'sinatra' require 'haml' helpers do end |
| require
'rubygems' require 'sinatra' require 'haml' module helpers def self.dosomething(arg) end end get '/' do Helpers.dosomething end |
Running at Rails Conf, Las Vegas 2009
Six of us from @railsConfRunner
ran together around Las
Vegas Hilton this morning.

6.4 miles, 57:04 minutes.
Interested in running together ?
Join us at 6:15am in the Hilton lobby tomorrow morning! Here is a
picture of the running group from this morning:
Thanks to Jed (2nd from right) for organizing the run, and of course
all the running
buddies to make it a fun run :)
Technorati: conf
railsconf
lasvegas
hilton
running
Posted by Arun Gupta in Running | Comments[0]
|
|
|
|
| TOTD #81: How to configure "database.yml" to be used with both JRuby and MRI ?
In JRuby-on-Rails
tutorial at Rails
Conf 2009, Nick
Sieger shared a nice little tip on how to configure
"database.yml" to be usable with both JRuby and MRI:
| <% jdbc = defined?(JRUBY_VERSION) ? 'jdbc' : ''
%> development: adapter: <%= jdbc %>mysql encoding: utf8 reconnect: false database: myapp_development pool: 5 username: root password: socket: /tmp/mysql.sock # ... |
Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Today's Page Hits: 1823
Total # blog entries: 1002