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

Posted by Dmytro Shteflyuk on under Ruby & Rails (4,361 views)

Ruby on Rails Routing

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 »

Memo #5: Use ary.uniq method carefully in Ruby

Posted by Dmytro Shteflyuk on under Ruby & Rails (7,290 views)

Today my friend asked me to help him with an unexpected behavior of Ruby’s Hash.uniq method. Here is an example:

1
2
3
4
5
6
[{"id"=>667824693}, {"id"=>667824693}].uniq
# => [{"id"=>667824693}, {"id"=>667824693}]
[{"id"=>66782469}, {"id"=>66782469}].uniq
# => [{"id"=>66782469}]
[{"id"=>6678246931}, {"id"=>6678246931}].uniq
# => [{"id"=>6678246931}]

Read the rest of entry »

Memo #4: Managing Ruby Gems

Posted by Dmytro Shteflyuk on under Ruby & Rails (3,891 views)

RubyGems 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 #3: Advanced usage of Ruby hashes and arrays

Posted by Dmytro Shteflyuk on under Ruby & Rails (5,824 views)

Ruby One of the most used features in any programming language is a Hash. Today we are going to talk about some of the Ruby’s Hash features, which are well documented, but rarely used — parameters of the Hash constructor. In the second part of this article we will take a look at the arguments of the Array class’ constructor.

Read the rest of entry »

Memo #2: Полезные трюки при работе с удаленными ветками Git

Posted by Dmytro Shteflyuk on under Development · English (6,591 views)

Git Здесь, в Scribd, мы используем Git как основную систему контроля версий. Каждый день создается, сливается и удаляется множество веток. Надеюсь, я когда-нибудь опишу наш рабочий процесс с использованием Git, а сегодня попробую рассказать о несколько полезных техниках работы с этим замечательным инструментом.

Подразумевается, что вы знаете, что такое Git, и как с ним работать. Ниже вы найдете несколько интересных трюков, который должны быть вам полезны (как минимум, они были полезны мне).

Read the rest of entry »