Fixing active record issue