Here I write about things I stumple upon
when doing my job, crafting web applications.

Sass 3.2 blocks

A lot of websites have side bars. On normal desktop browsers, this fits nicely. But on smaller screens, it will create horizontal scrollbars. And those are a bad user experience. Luckily, CSS supports @media directives that act on different sizes.

Sass 3.2 is going to ship with an awesome new feature: blocks. Just like Ruby. Instead of yield, you use @content. The rest is exactly the same. You can place anything inside your blocks: selectors (like table.products) and rules (like border: 1px solid gold).

The Sass documentation mentions that you can use it to specify it for IE6 compatibility, but I like it most for making my design responsive. Just create a mixin that places the @content inside the @media directive.

→ read more

Testing ActiveRecord in isolation

Testing ActiveRecord doesn't have to be slow. With some clever loading you can require only the parts that you need and it isn't even that difficult.

Another reason might be that you're using ActiveRecord without Rails. This might be in another framework like Sinatra, or in a gem. Without Rails you might be lost a little on how to set up ActiveRecord.

→ read more

Backends in Rails 3.1

If you find yourself needing a backend interface, you can either get an admin plugin of the shelf, like RailsAdmin or ActiveAdmin, or build your own. The of-the-shelf options provide a lot of functionality and are really worth a look.

You can also build your own backend. Building your own gives you maximum freedom. It requires a bit more work, but it might be preferrable, especially if your customer also needs to work with it.

There are some awesome tools out there to help you build your own backend. I'll show you how I would go about making such a backend. I'm using Rails 3.1 (the rc5 at this moment) on Ruby 1.9.2. I might gloss over some details here and there, so use your own expertise to fill in some gaps.

→ read more

Cucumber vs. Steak

Jeff Kreeftmeijer talked about Cucumber and Steak at the last Amsterdam Ruby Meetup. He hit upon an important theme in software development: reducing complexity; in this case the extra layers of complexity introduced by Cucumber features and step definitions. And he's absolutely right. If you don't need the natural language Cucumber provides, then you should get rid of the extra complexity and use Steak instead.

As much as I agree with this, I think there is a way of using Cucumber that makes it a valid option to use it in more cases than you think. It's for doing Behavior Driven Development with a high focus on the problem you're trying to solve. Let me explain what I mean by this.

→ read more

Want more?

See the rest of the articles.