Refactoring of RoR code

according to ReSharper
Smal fixes