Bootstrap-sass mixins cheat sheet

I've been working with Twitter Bootstrap a lot lately and the absence of any mixins list was driving me crazy.

Until now. I've created a simple app that parses SCSS files of bootstrap-sass gem and creates a neat list (with additional links to GitHub so you can quickly see the code snippet and make sure you're using the right one).

You can see it here, on my new playground server I'll be using for projects like this one.

If you have anything you wish to add or modify, feel free to send me a pull request!

Rails Magic #1

Sometimes during my work I find small things that confuse me, make me laugh or are the result of too much coding. From now on I'll post them under one "Rails Magic" banner.

I was looking for a way to prefix a path without prefixing a named routing helper. Somehow during the extensive two hours of hacking through the system I managed to end up with this brainfart:

scope '', :as => '', :path => 'abc' do
  get '' => 'home#index'

What's so funny about it? Except the totally redundant '' part in scope (I spent too much time in legacy code and forgot it's actually optional) there's a peculiar behaviour when we use empty string for :as param and nest few of these scopes together:

scope :as => '', :path => 'abc' do
  scope :as => '', :path => 'def' do
    scope :as => '', :path => 'ghi' do
      get 'abc' => 'home#index'

This routing results in named routing looking like this:

___abc    GET    /abc/def/ghi/abc(.:format)   home#index

For every empty :as it prefixes named routing with _. The solution? Simply skip the :as => '' and the first parameter. scope :path => 'abc' works just fine and I have completely no idea why I was trying to use the :as param all that time :)

Cells done right (for some definitions of "right")

As you may remember, I wrote a piece about Rails cells some time ago. To be honest I'm suprised on how many people have stumbled upon this entry - it's on the fourth position (or fifth; or third; depends mostly on personalized Google search) for "rails cells" phrase on Google! That and my recent experience with my fellow programmers writing their own cells have finally motivated me to write the next post in the series about cells. This time I'll write about some patterns and antipatterns I found common in my friends' code.

Read more