JSON.stringify() on arrays:
// JSON version 1
 => ""
// JSON version 2
 => """"
We’re not sure if this is a bug or a feature. We’re sticking with JSON version 1 until further notice.
Pivot Adam has a very interesting blog post about functors called Give up the func. Check it out!
Ask for Help
“We were having problems when mocking an ActiveRecord association under Mocha when we called
expects on a method that calls a method.”
The solution was basically to not mock associations.
“Mod_rewrite + SSL was causing problems when redirecting to a subdomain behind SSL.”
A wild-card SSL certificate solves the problem.
- In response to our ask for help, Ray Baxter answered us in code with a script called Firefoxen. “It’s a script to automatically configure multiple installations of Firefox so that they open with different profiles.” You can grab Firefoxen on GitHub. Thanks Ray!
IE7 sends odd
Accept headers (
*.* instead of an explicit
text/html) which can cause undesired behavior in Rails. Someone suggested manually setting the format in a
params[:format] ||= 'text/html'
This was discouraged because it can cause problems elsewhere. A better solution was to put the html format at the top of any `respond_to` blocks:
respond_to.html # run by default when type cannot be determined
The Ruby MySQL Gem version 2.7 leaks memory for very large queries. The solution is to remove the 2.7 gem and manually install version 2.8 from source. This library is no longer a gem and must be installed from the mysql-ruby-2.8 tarball.
Ask for Help
“As a followup to Firefox SSL certificate problems…”
It turns out that our server running nginx had an old version of OpenSSL installed. Upgrading OpenSSL solved the problem.
Ask for Help
“We’re having an issue with a long running Ruby process consuming too much memory and failing. What tools are available for finding and patching Ruby memory leaks?”
Several tools were suggested:
- Valgrind – Considered very powerful but difficult to use. “It will do what you want if you can figure out how to properly ask it to do so.”
- BleakHouse – Ruby specific leak detection. It’s available as a gem called “bleak_house”
- Leaks – This is native to OSX. The Google Web Toolkit uses this for leak detection.
- DTrace – Also a native OSX tool. There was a RailsConf presentation on Everyday DTrace on OSX.
“Rake will often silently ‘fail’ when running RSpec. It will not blow up but rather silently quits in the middle of the suite. This seems to happen intermittently, usually on the first run of our test suite. If we run the suite again, it works.”
It was suggested that this might be a Rake version issue since there have been other test suite problems with Rake 0.8.3. Though, this particular type of problem was not identical to previous Rake versioning issues and may be something altogether different.
Keep reading for a more detailed description of this weird RSpec + Rake issue.
More on the RSpec + Rake issue:
“It always manages to go through the integration tests, but when it hits the main tests, it will randomly quit (without a failure or error message) before all the tests are complete. At this point it’ll give us a summary message (X tests run, X tests passed) as if no other tests exist. We’ve worked on the problem a little bit this morning and tried the following things, all without success: >1) upgraded to the latest version of rspec and rspec-rails (1.1.11)
2) downgraded from rake 0.8.3 to 0.8.1
3) tried running with rspec and rspec-rails gems only
4) tried running with rspec and rspec-rails plugins only.
We’ve tried it on another machine with similar results. Right now, I want to say it only happens when we’ve modified a file in the project, but that may be confirmation bias (we ran about 60 full rakes on one machine where we have not been mucking about in the codebase and it seems to have successfully run all of them).
There was one other mention of this online in this ticket: http://rspec.lighthouseapp.com/projects/5645/tickets/587-conflict-with-loadby-and-reverse#ticket-587-3, paraphrased below:
‘This was caused by an error in handling a certain mal-formed spec; it was causing rspec to exit silently in the middle of one spec file. As I would edit files, –loadby mtime would cause them to load in different orders, which would then run different #s of examples because it would hit the file, and then quit silently, in different places’
You can close this one, I’ll report another bug that’s appropriate for the silent-exit-without-exception problem.”
Anyways, at this point we’re out of ideas and are leaving the problem behind for now, but we’d love to fix it, as it makes testing somewhat unpredictable.”
Nivi, from Venture Hacks, wrote a great article about why Pivotal Tracker is great for startups. It’s worth reading even if you’re already a fan of Tracker, and nails down the key ingredients to successful project management. Check it out:
- Teaser: Selenium for Flash! We’ve developed a Selenium-like framework for Flash. It’s pre-alpha, and needs to be extracted from it’s current home inside a project. Are you interested in a Selenium-like framework for Flash, or have you written one yourself? Let us know!
STI-weirdness. Rails surprise of the day: given a query of a
has_many :photos where Photos has STI subclasses (got that?) Rails will build a SQL query that includes the subclass types of Photo, which you might not want:
# query will have "... WHERE type IN ('Photo', 'OriginalPhoto', 'ThumbnailPhoto')"
It appears that the retardase_inhibitor might not work with Rails 2.1.X due to fixes in ActionMailer.
- JetBrains has been hard at work: they have released both a new Ruby plugin for IntelliJ, and a ruby-specific IDE (based on IntelliJ) named RubyMine.
Check out Pivot Jonathan’s wife’s art exhibit at Artist-Xchange Gallery in San Francisco, Friday 11/7 from 7-10pm:
3169 16th Street
Ask for Help
“I want to create a custom launcher for Firefox 2 and Firefox 3 with different profiles. Perhaps the real question is how do we create a custom version of a Mac application launcher, passing in the arguments we need?”
… without having to invoke it on the command line every time.
“We’re trying to delete cookies in our Controller, but they keep appearing in the headers anyway.”
Suggestion: make sure you are specifying your URL paths and domains correctly.
“Why won’t our CSS and other assets load the first time when accessing an SSL-protected domain on Engine Yard?”
It’s most likely not Engine Yard or Firefox 3′s fault. More research needed.
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?”
- It’s election day! If you are taking the time to read this geeky blog, you better have voted!
Ask for Help
“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:
s = Float::RailsNumberHelpers.number_to_currency(self, :unit => '', :precision => 2).chomp('0')
- ARMailer and ExceptionNotifer: A match not so much made in heaven.
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.
Ask for Help
“Is it okay to load a Flash widget multiple times on a single page?”
General murmuring led to the conclusion that this works fine.