neo
neo

Reputation: 4116

redirect to index if status code 500

I've added this to my show action on my controller:

redirect_to shows_path, status: 500

doesn't seem to be doing the trick.

I just want it to go to show index whenever there's a internal server error (500) for the show action.

Upvotes: 1

Views: 129

Answers (1)

Unixmonkey
Unixmonkey

Reputation: 18784

Although I think this would be a bad thing to do from a usability standpoint, you could add a rescue clause that is only triggered when an exception is thrown:

def show
  # do whatever you do
rescue
  redirect_to shows_path, error: 'Something bad happened'
end

Upvotes: 1

Related Questions