Use the following link in a new and edit view:
link_to 'Cancel', @cat
- In the
newview:@cat.new_record?istrueand the link points to the index page - In the
editview:@cat.persisted?istrueand the link points to the show view of the model