Simplifying your Ruby on Rails code: Presenter pattern, cells plugin

(Ruby & Rails) (24,037 views)

Today we will talk about code organization in Ruby on Rails projects. As everybody knows, Ruby on Rails is a conventional framework, which means you should follow framework architects’ decisions (put your controllers inside app/controllers, move all your logic into models, etc.) But there are many open questions around those conventions. In this write-up I will try to summarize my personal experience and show how I usually solve these problems.

Read the rest of entry »

Creating a simple but powerful profiler for Ruby on Rails

(Ruby & Rails) (4,182 views)

You are developing a large Web application. Controllers are full of complex data retrieving logic, views contain tons of blocks, partials, loops. One day you will receive an email with user complaints about some of your pages slowness. There are many profiling tools, some of them are easy (ruby-prof), others are large and complex (newrelic), but regardless of this it’s really hard to find the particular place where you have a real bottleneck. So we created really simple, but über-useful tool for ruby code profiling.

Read the rest of entry »

Memo #6: Using named routes and url_for outside the controller in Ruby on Rails

(Ruby & Rails) (3,011 views)

Sometimes we need to write small console scripts which do some background processing on our models. In Scribd we are using Loops to run these tasks (check Alexey Kovyrin’s introduction post). One of our scripts supposed to generate some sort of html reports, and we need to generate links to our site there.

Read the rest of entry »

X1 Tech Talks #1: Scribd Architecture Overview

(Presentations) (4,258 views)

Scribd Yesterday there was a first tech talk in the new co-working office X1, where I’m working now. I was talking about Scribd.com architecture (the big picture, almost no deep details). There are many things I’ve mentioned in this talk: nginx, haproxy, squid, mysql, sphinx, monit, memcached, Ruby on Rails, Amazon Web Services (EC2 and S3). Pretty interesting thing is that there was much more questions about Sphinx than about other tools.

I think it was pretty nice and successful, because I got many questions (really, really good ones), and instead of one-hour introduction we spent more than two hours in discussions and talks. I was enjoyed.

Below you could find slides from my talk (in English) and video recorded during session (in Russian).

Read the rest of entry »

Memo #1: Установка библиотек mysql и memcached (gems) под Mac OS X и MacPorts

(Ruby & Rails) · English (6,004 views)

Я уже очень давно ничего не писал в блог. Теперь сложновато начать, потому я решил написать серию коротких постов с подсказками и хитростями под названием “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 »