Use the following link in a new and edit view:

link_to 'Cancel', @cat
  • In the new view: @cat.new_record? is true and the link points to the index page
  • In the edit view: @cat.persisted? is true and the link points to the show view of the model