Not so far ago I have found a weird bug in the Open Source Ruby gem called composite_primary_keys, occurred when you specify :primary_key option for has_one or has_many association. There are two ways to get it fixed: submit an issue and wait till someone will work out this problem or fix it by yourself and then pull request to get the patch merged into the core. This is a great library and I use it in almost all my project, so I decided to help the author and fix this bug by myself. Here I will show you how to do that.
Read the rest of entry »
The power of Ruby is not only in its flexibility. It allows to create easy to maintain reusable parts of software, and also provides a way to redistribute them and integrate with your applications — RubyGems system. The only thing that could hurt developer’s brain is managing installed gems. When you are updating already installed gem, previous version will stay in gems folder and will be available to use. But why do you need all these obsolete libraries? There is a command to cleanup stale libraries in RubyGems — gem cleanup.
Read the rest of entry »
Я уже очень давно ничего не писал в блог. Теперь сложновато начать, потому я решил написать серию коротких постов с подсказками и хитростями под названием “Memo“. Сегодня я хочу поговорить о двух библиотеках (gems) Ruby, которые использую в каждом проекте на Ruby on Rails: mysql и memcached. Каждый раз, когда пытаюсь установить или обновить эти библиотеки под Mac OS X, я получаю следующую ошибку:
1 2 3
| Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension. |
После чего начинаю лихорадочно гуглить на тему как же мне все-таки их установить. Настало время упростить себе жизнь и описать процесс установки здесь.
Read the rest of entry »