Articles

Say “hello” to George Hills

george_hills_author

All of us at Brightbox towers are very pleased to welcome George Hills to the team.

George, who joined us earlier this week, is an experienced Senior Systems Administrator and a networking expert.  He will be working within our Operations team to both manage our existing hosting infrastructure and develop our new “cloud” systems.

Lightning talks

You'll notice on the conference program, a section for Lightning Talks. If you've got something that you'd like to share, the floor is open for you to chat for 10-15 minutes on any topic you think people will find interesting. The mic and data projector will be available should you want them, too.

We'll also be keeping the mic on during tea breaks and lunch, so if you have something you'd like to point out, advertise a job, tell your favourite joke, or suggest the best pub in the area, feel free :)

Sponsor News, book discounts

Manning, publisher of books such as The Well Grounded Rubyist and Ruby in Practice (and many others) are offering a 35% discount to everyone attending the conference. You could even pre-order Rails 3 in Action (due in February 2010, but available via early access)

A postful of shortcuts

Some quick links to popular pages, all in one place:
Conference Registration, and information about the venue.
The free BDD & Cucumber Workshop information & registration

Talk: Working with Legacy Rails Apps - Technical Debt Hell and how to work your way out of it, Desi McAdam

Details

Many of us have found ourselves having to deal with a difficult Rails
codebase. Maybe you wrote it before you got good at Rails. Maybe you
are rescuing a disaster caused by someone else. Many times our gut
reaction is to scrap the legacy codebase and rewrite, but what about
times when that isn't a feasible approach? What to do?

Double Shot #497

Up late deploying stuff last night, so just a couple of quick links this morning.

Bond - From Irb With Completion Love

Bond is on a mission, as usual. This time it’s to make custom autocompletion dead easy in Irb. Simply order Bond to complete arguments, methods or your own twisted regular expressions and they will be executed. No questions asked.

Bond’s Coordinates

Bond’s getting old nowadays, regardless of what Hollywood says. So old that I even got his coordinates:

  gem install bond

Debrief

Let’s say you want to autocomplete some quoted arguments for a couple of methods. Here’s how you could do that in Irb:

Original Author Name: 
Gabriel Horner

Alias: Enhance Your Ruby Console/irb Experience

aliasA couple of weeks ago we featured Gabriel Horner's Hirb framework for formatting irb output.

Behind the scene: Quiltivate.com a beautiful Flex on Rails website.

I met Phil several years ago at Derailed, the (Denver Ruby on Rails user group, and for a long time he was curious about how Flex can be integrated with Rails, about the graphical possibilities that Flex offers, the advantages over plain HTML/CSS/Javascript. Then he told me Kacie, his wife, had an idea about a website. She is passionate about quilts and has an eye for details and excellence. Phil is a geek that loves Rails, Kacie loves quilts, it's like Quilting meets Web 2.0 and quiltivate.com was born.

GitHub Meetup SF

We’re going to try and hold a GitHub Meetup in SF every fortnight (read: two weeks) at a bar or restaurant. After all, the best part of any tech meetup is the drinking!

The first one will be held tomorrow, July 16th at Kilowatt in the Mission at 7:30pm. First round’s on GitHub! Just look for me or mojombo (picture reference).

Rails meets Sinatra #2 - Mix n' Match | Rails Fire

Rails meets Sinatra #2 - Mix n' Match

In my previous post, we saw how to mount a sinatra application at a specific location for a regular application. But using Rack::Cascade, we can take that solution to a whole new height. That is :

  • Put sinatra code in any of your regular Rails controllers.
  • No need to mount at Sinatra at a specific URI.
  • Have Sinatra work for any URI, gracefully fallback to Rails if no Sinatra method matches the path.
  • Use your models/libraries etc. in both Rails and Sinatra.

So your controllers can look like :

1
2
3
4
5
6
7
8
class HomeController < ApplicationController
  get '/' do
    Item.count.to_s
  end
  
  def index
  end
end

and even :

1
2
3
4
5
6
7
8
9
class SiteController < ApplicationController
  get '/:name' do
    Site.find_by_name(params[:name]).html
  end

  def new
  end

end

And environment.rb:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
RAILS_GEM_VERSION = '2.2.0' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  config.gem "sinatra"
  config.time_zone = 'UTC'
  config.action_controller.session = { :session_key => '_monkey_session',  :secret => 'whatever' }
end

set :env, :production
disable :run, :reload

# Remove trailing slash from URIs reaching Sinatra
before { request.env['PATH_INFO'].gsub!(/\/$/, '') if request.env['PATH_INFO'] != '/' }

# Checking AR Connections back to the pool
after { ActiveRecord::Base.clear_active_connections! }

# Preload controllers with Sinatra code
require 'home_controller'
require 'site_controller'

And most important, the rack setup file :

1
2
3
4
5
6
7
8
9
require File.dirname(__FILE__) + '/config/environment'
require 'thin'
  
app = Rack::Builder.new {
  use Rails::Rack::Static
  run Rack::Cascade.new([Sinatra.application, ActionController::Dispatcher.new])
}.to_app
 
Rack::Handler::Thin.run app, :Port => 3000, :Host => "0.0.0.0"

And start your server !

[lifo@219 monkey]$ ruby racked.rb

Images: