Ask for Help
“console.log seems to be broken again in Firebug with 1.2.1?”
People have had some success with 1.3 beta. Get Firebug
“Suggestions for creating PDF’s in Ruby?”
“console.log seems to be broken again in Firebug with 1.2.1?”
People have had some success with 1.3 beta. Get Firebug
“Suggestions for creating PDF’s in Ruby?”
“Is there some order-dependency issue with `has_many_polymorphs?”
We have a test that passes in isolation, but fails when the whole file is run.
“Any advice to setting up Lucine to allow us to search for strings with special characters, such as ‘-’, without having to wrap them in quotes?”
We have some Lucine knowledge here but feel free to give us your suggestions as well.
We’ve released the first version of the Tracker API. It’s a RESTful HTTP XML interface, uses a simple, token-based authentication mechanism, and allows you to query as well as update stories in your projects.
To get started with the API, read through the API Help page (it includes examples), and create a token on your Profile page.
We plan to enhance the API and add support for more operations and formats (including JSON) based on your feedback. Please let us know what you’d like to see added, either by email or via Satisfaction.
We have a project that generates a lot of highly precise floating point numbers. However, we primarily want to display these numbers with only two decimal places of precision. In addition, we want to display these numbers with standard comma delimiters to the left of the decimal point.
Sadly, the Ruby #sprintf method provides the former functionality, but not the latter. What to do? Use a Rails helper, of course.
The NumberHelper from ActionView provides some useful functionality, so we used that. As it turns out, we found the best way to get the formatting we want to be using the #number_to_currency function with no denomination.
Also, rather than mixing the entire helper into the Float class for just one method, we chose to mix the helper into a nested class and expose only the functionality that interests us. The result looks something like this:
class Float
class RailsNumberHelpers
extend ActionView::Helpers::NumberHelper
end
def formatted
s = Float::RailsNumberHelpers.number_to_currency(self, :unit => '', :precision => 2).chomp('0')
end
end
If you use the ExceptionNotifier plugin (and if you don’t, why not?) and you install the ARMailer plugin, your app will stop sending the exception notifications. You have been warned. Initial reports suggest that fixing the problem is relatively straightforward.
For those not in the know, ARMailer is a plugin that queues all outbound email in your database, to be sent later by a cron job or something similar. Good for not clogging up your server with email processing during peak load.
“Is it okay to load a Flash widget multiple times on a single page?”
General murmuring led to the conclusion that this works fine.
position value. We were hiding the Flash widget by moving it’s containing div off the page with position: absolute; left: -9000, and removing the class that had those values to show it again. It turns out that changing that position value causes the Flash to reload. By keeping the position:absolute setting when we both show and hide our container div, the Flash no longer reloads.“When using Rails’s date_select helper, is there a corresponding helper method to turn that date format into a Date object in the controller?”
Some Snippets are available, but how about a Rails built-in solution?

Ian McFarland and I attended a 2-day Development Forum hosted by OpenView Venture Partners last week in Boston. It’s the second year that Pivotal Labs has participated in the event. Open View has a portfolio of companies from all over (Europe, Australia, the US), each of which has been working on implementing Scrum over the past year. The engineering staff from 10 portfolio companies attended the event. Jeff Sutherland (amongst other things the co-creator of Scrum) is a Senior Adviser to OpenView; he provides advice and guidance to the portfolio companies as they progress through their Scrum adoption, and he gave a talk at the Forum. Pivotal Labs was invited to speak and lead a discussion of on 2 core topics: Developer Testing and the Principles of Build.
First, we heard from each company on how they were doing with their adoption of Scrum and on the following two questions on the subject of technical developer practices:
The 10 portfolio companies come from a disparate set of industries and technical domains, so Ian and I were very interested to hear each of their histories with Scrum and the current issues they were facing with respect to these 2 questions on developer practices. Some were at a fairly advanced stage – they had good test coverage and a stable CI setup – and some were just getting started. The most frequently stated barriers to achieving the goals of fully tested software that’s ready to release were:
Pivotal’s first talk was on developer testing. There were two main points we wanted to make:
Rather than the traditional model of a QA team being almost solely responsible, consider a shift towards the whole team being responsible, and in particular a much greater emphasis on developers owning quality. For many developers it’s a radical shift.
During the talk I gave a demo of a simple example of strict TDD, which gave rise to some useful conversations; as expected, the reactions varied from “yes, that’s what we do” to “that makes no sense!”. Having coded solely with strict TDD for almost 9 years now, and being around Pivots who exclusively test-drive also, it’s always interesting to hear reactions of people coming to TDD for the first time. The idea that tests are the center of the development effort, and that code is to some extent expendable, is a radical shift in thinking. We also touched on the benefits TDD brings in addition to reducing regressions. I find that a useful question to ask is what TDD stands for: “Test Driven Development” or “Test Driven Design”. The notion that TDD helps in designing your object model brought up some interesting discussions (for example, mock objects came up).
We also tried to address the barriers to adoption that had been brought up:
We made two points about speed when doing TDD:
Our second talk was on build. As an ideal to shoot for, we promoted what Pivotal Labs does:
There was a good deal of discussion over how to get started with a build. Some ideas that were brought up were:
Hopefully our talks were useful. Certainly they sparked plenty of discussion!
Thanks to Jeff Sutherland, Igor Altman and Steve Rabin of OpenView for inviting Pivotal Labs to speak.
Below are our two presentations.
this_method method! The magic is in the REGEX, of course.
module Kernel
private
def this_method
caller[0] =~ /`([^']*)'/ and $1
end
end
describe "MyMagicModule Mixin" do
before(:all) do
ActiveRecord::Base.connection.create_table "some_base_models",
:force => true do |t|
t.string "name"
t.string "type"
t.integer "some_model_b_id", :limit => 11
end
end
after(:all) do
ActiveRecord::Base.connection.drop_table "some_base_models"
end
class SomeBaseModel < ActiveRecord::Base;end
class SomeModelA < SomeBaseModel
include MyMagicModule
belongs_to: :some_model_b
end
class SomeModelB < SomeBaseModel
include MyMagicModule
end
it 'should use special belongs_to stuff from MyMagicModule' do
model_a = SomeModelA.create!(
:name=> "Model A",
:some_model_be => SomeModelB.create!(:name => "Model B"))
# test the functionality from MyMagicModule
end
end
“Can we use migrations to load static data into an application”
People usually create a separate rake task to bootstap. Mixing it with migration was not working well before.