If you like it, I donโt need the behavior of link_to "cancel", :back , you can implement a helper method that either refers to the record index path or the path to it. (i.e. teams_path or team_path(@team)
module CancelFormButtonHelper def cancel_button(record) index_path = record.class.to_s.pluralize.downcase + "_path" path = record.persisted? ? record : eval(index_path) link_to "Cancel", path end end
which can then be used as <%= cancel_button @team %> in the form, for example.
Dan Andreasson Oct 18 '16 at 14:17 2016-10-18 14:17
source share