company-logo

Installing mysql gem with bundler on Snow Leopard

Between 0.9.26, RC and final 1.0 release, bundler went thru some heavy changes with respect to command line options it supports. Luckily, twitter, forum and blogs kept everybody in the loop. The blogs, however, became obsolete quickly and even blog posts few months old don’t work with latest version of bundler. We came across this issue that kept is in a loop for a while. Snow Leopard changed a few things with
Read More

Monitoring rails processes (apache, passenger, delayed_job) using god and capistrano

When it comes to monitoring servers and processes in production, there is quite a few open source tools: nagios and hyperic are proven solutions for enterprise apps. Monit and god are the favorites of ruby/rails community. God has been around for a few years now and most critical issues with god seem resolved. So, I decided to use that on my project. If you’ve worked with any deployment related stuff before, yo
Read More

Using Bundler with rails 2.3.X

Bundler is optional for rails 2.3.X. However, it is not a bad idea to upgrade to bundler for several reasons: It is stable now and will solve your gem dependency conflicts better than rubygems require. You will be better prepared to migrate to rails3 when you are ready. Instructions for using bundler with rails 2.3 will get you off to a good start. We use shoulda and mocha for our test suite. If you do too, you may r
Read More

Login as multiple users simultaneously for testing

Ever wondered how to login as two different users at the same time? The situation manifests in any project where you want to be able to test a workflow involving several actors with different roles. The problem is that browsers allow only one login for a given domain at any one time. So, you are required to logout as current_user before logging in as another. One of the solution people use is install multiple browser
Read More

Disabling form post in google chrome and safari

So, I found this issue with google chrome and safari web browser and I believe this applies to any webkit based browser. When a form submit is disabled by setting the submit button to disabled=true attribute, the browser is usually expected to prevent submission when the user hits “ENTER” on any of its text fields. This works fine in Firefor, my default browser. In my rails app, I had to do this to work a
Read More

Rails Email Unit Testing

ActionMailer classes, for sending out emails, typically reside with models, inside app/models folder. Yet, they have traits that are similar to controllers. For example, each actionmailer class has a view folder inside app/views where email templates are defined. And testing support for email is provided as functional tests with assert_select macros such as assert_select_email. In my current project, most of our emai
Read More

Internet, Email, Blogs, Forums … did we need twitter?

Yes, we did. And here’s why. I was at a recent social gathering where we started talking about how funny and bizzare it is that people use twitter to post messages like .. sh**, woke up late .. having lunch at Gino’s East … driving to work … my dog peed on my bed … . .. Oh ok, that last one is probably out of thin air but posting those kinds of messages probably don’t add much valu
Read More

Optimizing has_role? in acl9

acl9 is a an authorization library for rails applications. It is one of the widely used library if not the most widely used now. Our experience with acl9 shows that it might be heavy weight if your authorization needs are simpler (which most projects are) but could be useful for other projects. If you’ve used acegi/spring-security for authorization in your java apps, you know that acl9 is very similar in princi
Read More

Unit Testing Sphinx

Sphinx (and its rails plugin thinking-sphinx) is my choice of search engine on ruby/rails project. It is powerful yet super easy to setup. However, testing Sphinx code is not easy at first. Since Sphinx works by leverging database commit hooks, it cannot be tested within the bounds of unit testing framework that rails provides. This is understandable because, in rails testing, a transaction is started before each tes
Read More

Ruby/Rails: Loading Seed Data for Tests

Fixtures are notorious in rails. To get around issues like brittleness and multiple file flipping to understand single test, there have been better approaches using gems like fixture_replacement, machinist and factory_girl. No complains there. In my experience, fixture are still great for one thing: loading seed data. This is because seed data is often used by many many tests and they don’t change often and hen
Read More