Extracted code from Rails project