In my controller, I want to handle an ActiveRecord::RecordInvalid exception by redirecting back to the controller action that caused the exception with a flash message, but I also would like to retain the form data that the user entered. Is there a best approach for dealing with this?
rescue_from ActiveRecord::RecordInvalid do |exception|
redirect_to :back, alert: exception.message
end
This currently redirects and shows the flash message properly, but I'm not sure what the best practice is for retaining the form data. Thanks in advance.