Fixing bug in rails