flash[:error] should be set in controller, and not in the view. Remove from here, and put in controller.