Brandon Keene's blog
Interesting Things
- The iPhone SDK version 2.2 was released.
- An interesting Selenium Object Pattern was discussed.
Ask for Help
"How big should a typical mongrel be? Ours is starting out at over 200 megs but is not leaking from that point."
Everyone agreed that 50MB to 70MB is standard and anything over 100MB is considered pretty big. People suggested RubyProf for inspecting object counts and possibly tracking down the memory hogging code.
"What pattern does everyone use for non-model Reports with ActiveRecord? We are trying to create a report that counts a single model and groups by two associated models"
There was consensus around modeling a distinct report object and calling the referenced models. For example, FooReport and FooReportController fit nicely in a RESTful Rails world.
Interesting Things
- ActiveScaffold was surprisingly easy to use for admin interfaces. One possible gotcha is that you have to manually configure namespaced RESTful routes (e.g.
map.resources :tasks, :active_scaffold => true).
Ask for Help
"What are your current favorite Object Mother implementations or patterns?"
There are several approaches:
- Factories-and-Workers
- Object Daddy
- Roll Your Own - Your Object Mother will likely be so domain specific that you should just write it from scratch.
"Does anyone know how to disable caching in Safari? Caching can often break JSUnit between test runs"
Go to Develop -> Disable Caches and you get a fresh non-caching Safari.
Interesting Things
JSON version 2 has problems with its JavaScript implementation json2.js, specifically when calling
JSON.stringify()on arrays:// JSON version 1 [1] => "[1]" // JSON version 2 [1] => "\"[1]\""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
expectson 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.
Interesting Things
- 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
Acceptheaders (*.*instead of an explicittext/html) which can cause undesired behavior in Rails. Someone suggested manually setting the format in abefore_filter: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:def show respond_to.html # run by default when type cannot be determined respond_to.js end
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.
Interesting Things
- IntelliJ IDEA 8 was officially released over the weekend.
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.
